RSS Feeds

HTTP Caching Revisited

I find the issues around of Web performance very interesting.  I’ve researched pretty comprehensively and written a few articles in this area. I also routinely use various web tools to instrument sites that I visit to see how they perform, and quite frankly a lot are middling to terrible in performance terms.  An example is the MoneyCorp GPS application that I discussed in a previous article, I have subsequently found worse sites (e.g. the RadioTimes TV website which scores 18-25 depending on page), though in these cases the main effect is a case of loading slowly, rather than failing to load at all as in the case of GPS.

However, what I have noticed with some sites is that they seemed to perform reasonably well from a user-perspective even though Google PageSpeed marks them down for not specifying caching parameters.  The relevant Google recommendations on “Leverage browser caching” describe the use of the HTTP headers Expires, Cache-Control max-age, Last-Modified and Etag for resources that you wish cached by the client browser, as I have discussed perviously.  This guidance really only relates to the mandatory rules for browser caching detailed in RFC 2616 (HTTP/1.1) in section 13.2.  However, in addition to these mandatory rules, most browsers also implement an advisory rule that is discussed in section 13.2.4, and which is based on any Last-Modified header if provided.  If present, then life of the cached resource is the age at download (the delta of Date and Last-Modified values) divided by a factor X.  The factor “X = 10” is suggested in the RFC and this is what IE, Firefox and Chrome use.  So by example, if a resource is 10 weeks old at download, then its cached copy will be treated as valid for one week from download.

Apache and IIS both supply Date and Last-Modified headers by default for file-based resources, hence despite the general “best practice” advice on specifying these headers, such file-based resources will frequently be cached.

Conversely, script-based resources will not be unless the code explicitly emits the correct headers.

Post a comment

Please note that your name is required and that all posts will not be visible until authorised by an administrator.

  A valid mail address must be supplied
A cookie will store your name/url for three months
 Sorry, but you must answer this easy sum as a SPAM prevention measure.

You should be aware that all information on blog site is © Terry Ellison 2010 and made open access under the Creative Commons Artistic Licence.

Your comments will only publicly available after you have carried out email confirmation. Your email address will only used for this purpose and is not made public.

Comments that are not confirmed will be automatically deleted after 7 days.

The blog author reserves the right to delete comments which breach copyright or the rules of site etiquette as he determines (such as unnecessary use of obscenity or spam content).