Best Practices

Use GZIP compression

  • Reduces the size of data being transmitted to the device
  • Increases the speed of the data requests
  • GZIP compression is easily turned on by adding HTTP headers
Curl Example:
curl -H "Accept-Encoding: gzip,deflate" "{your key}"

  • Without compression, size=17695 bytes
  • With compression, size=2958 bytes
Java Example:
HttpUriRequest=new HttpGet({your key});
request.addHeader("Accept-Encoding", "gzip");
// ... httpClient.execute(request);

Top of Page

Randomize refresh rates

  • Add some type of randomization to the individual device refresh time so that all devices don't refresh at the same clock time.

  • For example, do not request updates on all devices at :00 and :30 past the hour

Top of Page

Use Expires header

  • Refresh information from the AccuWeather API for your device based upon the cache expires time in the response headers

   Response Headers
    Cache-Control: public
    Content-Encoding: gzip
    Content-Type: application/json; charset=utf-8
    Date: Wed, 29 Aug 2012 14:55:33 GMT
    Expires: Thu, 30 Aug 2012 14:56:34 GMT
    Server: Microsoft-IIS/7.5
    Server: Microsoft-IIS/7.0
    Transfer-Encoding: chunked
    Vary: Accept-Encoding
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET

  • In this example, do not refresh until: Thu, 30 Aug 2012 14:56:34 GMT

Top of Page

Timezone Offset Changes for Daylight Savings

  • If you intend to use the GMTOffset from the Location Api response to calculate times local to the location, you MUST be careful to observe the NextOffsetChange property. The offset will change on the date and time specified.
  • Using the expires header as described above will ensure that you have the most current GMTOffset for the location.

Top of Page

MinuteCast™ Caching

  • AccuWeather is working with global partners to expand MinuteCast™ worldwide. However, for locations where it is not currently supported, an HTTP 400 response is returned.
  • To reduce data consumption and prolong battery life in some devices, we recommend that developers cache MinuteCast™ HTTP 400 responses for 72 hours to prevent subsequent requests from returning the error.

Top of Page