Author: Jeff Verkoeyen

Etag Cache Support

First order of business, read up on Etags.

In summary:

An ETag (entity tag) is part of HTTP, the protocol for the World Wide Web. It is a response header that may be returned by an HTTP/1.1 compliant web server and is used to determine change in content at a given URL. When a new HTTP response contains the same ETag as an older HTTP response, the client can conclude that the content is the same without further downloading. The header is useful for intermediary devices that perform caching, as well as for client web browsers that cache results. How the server generates an ETag is entirely up to the server. One possible method of generating the ETag is based on the last modified time of the file and the size of the file, another is using a checksum.

Three20 supports Etag internally with the TTURLRequestCachePolicyEtag cache policy. By adding it to your request's cache policy, Three20 will follow the procedure required to support Etags.

request.cachePolicy = cachePolicy | TTURLRequestCachePolicyEtag;

See TTFacebook for an example.

The Three20 Etag procedure is as follows:

  • When a request is made, check whether we are using the Etag cache policy.
  • If we are, make the request and provide the cached Etag, if one exists.
  • Upon receipt of a 200 response, cache the Etag key if present.
  • Upon receipt of a 304 response, load the data from the cache.

blog comments powered by Disqus