Document browser caching behavior #50

Open
akavlie opened this Issue Feb 8, 2012 · 4 comments

3 participants

@akavlie

Even if you don't specify cache expiration properly in HTTP headers, despite all the warnings generated by tools like the Webkit auditor or YSlow, Chrome & Firefox pull static assets from local cache on subsequent visits to a site. It's difficult to find good information via Google/Stack Overflow searches about how this works, and the browsers themselves don't clearly report expiration dates.

How long will assets be cached? If assets are cached & retrieved locally regardless of server cache expiration headers, are the headers really that important?

@akavlie

In the app that brought this issue to mind, we've got Etags set for most static resources, but not cache expiration headers. YSlow & the Webkit audit tool throw a lot of warnings for that, but the assets are cached just fine in Chrome & Firefox. How long they will remain cached, though, is not clear.

Furthermore, unless you refresh the page, they don't even hit the server to check if the asset is changed (whereupon a 304 would be returned). They just go straight to local cache, which returns a status code 200.

@mattbrundage

IE, by default, uses heuristics to determine whether or not to load a file from cache if cache-control or expires headers are not present: See the section "Heuristic Cache Improvements".

@akavlie

Thanks Matt, that's a great resource for IE. I wonder if a similar writeup exists for Firefox/Chrome/Safari?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment