The heading "Expires" is very confusing here! Sometimes it works as expected - and sometimes not.
I use the following code to set expiration headers. Note that this is done with ASP.NET in a custom MVC attribute - it doesn't really matter here, but explains where it comes from 'filterContext'.
HttpCachePolicyBase cache = filterContext.HttpContext.Response.Cache;
TimeSpan cacheDuration = TimeSpan.FromSeconds(Duration);
// my own custom header so we know what time it was
filterContext.HttpContext.Response.AddHeader("CurrentTime", DateTime.Now.ToString());
cache.SetCacheability(HttpCacheability.Public);
cache.SetExpires(DateTime.Now.Add(cacheDuration));
cache.SetMaxAge(cacheDuration);
cache.AppendCacheExtension("must-revalidate, proxy-revalidate");
This sometimes gives me the following headers:
Cache-Control: public, must-revalidate, proxy-revalidate, max-age=413
Date: Wed, 18 Feb 2009 05:24:19 GMT
Expires: Wed, 18 Feb 2009 05:21:12 GMT
CurrentTime: 2/17/2009 9:21:12 PM
Sometimes it looks like this:
Cache-Control: public, must-revalidate, proxy-revalidate, max-age=600
Date: Wed, 18 Feb 2009 05:27:55 GMT
Expires: Wed, 18 Feb 2009 05:27:55 GMT
CurrentTime: 2/17/2009 9:27:55 PM
I run everything through Fiddler and look to see when everything is requested and when they come from the browser cache.
Now it’s strange that caching always works as expected. The link to my ASP.NET MVC action method appears in Fiddler, and then when I click the same link again, it comes from the cache.
Chrome ! , HTTP-.
, :
http://ipv4.fiddler:62669/gallery/mainimage/2
IE, 200 . Chrome . - .
Chrome - "" - ?
, - , Expires . google jQuery , ( Expires 2010 - ).
Cache-Control: public, max-age=31536000
Date: Wed, 18 Feb 2009 05:44:53 GMT
Expires: Thu, 18 Feb 2010 05:44:53 GMT
?
HTTP:
Expires , max-age , . , HTTP/1.1 ( ), HTTP/1.0 . , HTTP/1.0 , , - .
, Chrome max-age, "Expires" , , , .