3

I have a web site that is recieving many unexpected requests for static resources (images, css files etc) that I would expect to be being served straight from the browser's cache. This is a performance problem and I can't understand why it is happening.

For each static resource the web site returns an Expires header of 24 hours in the future, a Last-Modified header of the date of modification of the image/css file and an ETag:

Expires: Wed, 07 Dec 2011 13:50:47 GMT
Last-Modified: Thu, 14 Jul 2011 15:19:16 GMT
ETag: W/"4875-1310656756000"

With these settings I'd expect that, after the first time the browser requests an image or css file:

  • it would not re-request the resource for another 24 hours
  • after 24 hours it would re-request the resource, passing an If-Modified-Since header and an If-None-Match header, to which the server would respond with a 304 status (assuming nothing has changed server-side).

This is what happens most of the time.

However I see some browser sessions where the static resources don't appear to be cached and are requested for every page.

Looking at these requests I don't see any If-Modified-Since or If-None-Match headers being received. The server is then responding with a 200 status each time, and returning the requested resource. This is a performance problem that I want to track down.

I suspect that the problem is due to the presence of an HTTP proxy/cache between browser and web site (problem sessions usually come from behind corporate firewalls). If so, I don't understand why a Proxy would be interferring with the Expires/Etag/Last-Modified headers in this way.

A couple of pieces of additional info in case they are relevant:

  • I don't currently set a Date header. Is that needed for the Expires / Last-Modified headers to work correctly?
  • I don't currently set a Cache-Control header, having thought that Expires / Last-Modified would be "good enough".
  • The web site is deployed over both https and http, and I've seen the issue in both deployments. I'd thought that this would stop a proxy being the cause, but now understand that some proxies do intercept SSL traffic.

Has anyone else experienced anything similar and found out why it happens?

4
  • 5
    Remember, these mechanisms allow a browser to cache responses, but the browser is not required to perform any caching at all. Dec 7, 2011 at 12:41
  • Are the offending requests GET or HEAD requests?
    – ibid
    Dec 7, 2011 at 12:49
  • @Damien_The_Unbeliever: I understand that I can't force the browser to cache these responses. I'm trying to understand what settings / policies might be in place in the browser or proxy that could cause what I'm seeing. I have customers that experience the poor performance and would like to know how to improve it. Dec 7, 2011 at 13:48
  • Have you looked at the IP / useragent of these requests Mar 16, 2012 at 5:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.