HTTP "Expires" header does not work in Chrome

David S. picture David S. · Jul 19, 2012 · Viewed 9.3k times · Source

My system is Windows 7 x64, Chrome 20.0.1132.57 m.

In my HTTP response header, I have:

Cache-Control: public, max-age=1000
Expires: *some date*

In IE & FF, the page is cached in local, and when I try to access again by typing the URL and hit enter, no request is send and the page is displayed correctly. But in Chrome, it always send a request to the server with the following header:

Cache-Control: max-age=0

I do not want the client send a request to my server and then reply 304. I want to save the round-trip time.

Answer

Kristóf Dombi picture Kristóf Dombi · Aug 7, 2012

Be carefull when you are testing. I noticed that in Chrome version 20 if I hit F5 to reload the page then in the network panel I see new requests. Hoewer if I place the cursor to the title bar, after the current page url, and hit enter, I get resources from cache, whitch header was set to cache.

Also its better just use the max age. Max age and Expires is the same, but in max age you specify the duration.

See this: http://betterexplained.com/articles/how-to-optimize-your-site-with-http-caching/ Method 3 and Method 4.