After some testing and googling, it seems at least Firefox and Chrome ignore max-age when you refresh the page (but not when you navigate via links). Is it possible that you ran into that?

Indeed, I figured that part out pretty late, those browsers send cache-busting headers for Cache-Control on plain refresh, which is what you'd expect of a shift-refresh, not a plain one. The SO post has the comprehensive table listing the headers sent.

So, caching is working. My changeset has a limited benefit: it will make the browser cache work on plain refreshes as well.


On Mon, May 5, 2014 at 7:17 PM, Gergo Tisza <gtisza@wikimedia.org> wrote:
On Sun, May 4, 2014 at 10:58 PM, Gilles Dubuc <gilles@wikimedia.org> wrote:
It seems like the browser will not always pick up/respect the Cache-Control directive for the browser cache (I don't know why, could be specific to my machine/OS X and I've wasted many hours already trying to figure it out). I've found a workaround, which is using Last-Modified/If-Modified-Since (which will trigger the 304 mechanism) in addition to Cache-Control: https://gerrit.wikimedia.org/r/131425 It's probably worth having that in general anyway, for older browsers.

After some testing and googling, it seems at least Firefox and Chrome ignore max-age when you refresh the page (but not when you navigate via links). Is it possible that you ran into that?
This comment in the Chromium tracker has some explanation: https://code.google.com/p/chromium/issues/detail?id=1906#c6
I verified that this affects AJAX requests as well - the API requests are not cached when I press F5, but cached when I click on the "Page" tab (which links to itself) and reopen the same image.

Some of the answers to this SO question have a lot of details about caching behavior across browsers: http://stackoverflow.com/q/385367/323407