Use GZIP Compression

Randomize Refresh Rates

Use Expires Header

Timezone Offset Changes for Daylight Saving

 

 

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" "http://api.accuweather.com/locations/v1/search?q=san&apikey={your key}"
  • Size without compression = 17695 bytes
  • Size with compression = 2958 bytes
  • Java Example:
HttpUriRequest=new HttpGet(http://api.accuweather.com/locations/v1/search?q=san&apikey={your key});
request.addHeader("Accept-Encoding", "gzip");
// ... httpClient.execute(request);

 

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.

 

Use Expires header

  • Refresh information from the AccuWeather APIs 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

 

Timezone Offset Changes for Daylight Saving

  • 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.