Yahoo Weather API - load cached weather from server?

198 views Asked by At

We are using simpleweather.js, which pulls in weather from Yahoo Weather API. Yahoo often has issues, throwing an error that "weather data cannot be retrieved right now." This seems to be a common issue.

Is it possible to fetch the data on a schedule (maybe every 30 min), store it on our server and fetch it from there when the site is loaded? That way we’d be protected from the intermittent outages.

I've never done something like that, so I'm hoping someone can provide guidance.

Thank you!

1

There are 1 answers

1
wall-nut On

I had the same problem and implemented a server solution. I was requesting weather for 4 locations and getting all 4 back in about 1 out of 12 tries. So I run it every 2 minutes and only store the result if the count equals 4 channels returned.

The response time in the application is so fast the weather now displays as the page is rendering.

I wrote my server code in Perl. One script runs every 2 minutes and another script shapes the stored JSON string, so it can be used by the jquery zweather application. I have been updating the zweatherfeed.js to keep up with Yahoo! changes.

I am not using the OAuth public/private server. That server may be more reliable than the public server.