IE caching problem
In IE (8 at least, probably the rest too):
I make a request:
GET http://www.mydomain.com/ HTTP/1.1
the server responds with:
HTTP/1.1 200 OK
Cache-Control: private, must-revalidate
Last-Modified: Fri, 25 Mar 2011 10:52:34 GMT
Date: Fri, 25 Mar 2011 10:54:15 GMT
I make another request:
GET http://www.mydomain.com/ HTTP/1.1
If-Modified-Since: Fri, 25 Mar 2011 10:52:34 GMT
the server responds with:
HTTP/1.1 304 Not Modified
Cache-Control: private, must-revalidate
Last-Modified: Fri, 25 Mar 2011 10:52:34 GMT
I then goto some page, say:
http://www.mydomain.com/somepage
which has a link on it:
<a href="http://www.mydomain.com/">click me</a>
When I click this, IE displays the previously cached response for this the anchored URI, without even making a request.
Why is it not obeying must-revalidate
? This works as I'd expect in FireFox and Webkit
How do I make it obey it?
开发者_运维百科Thanks
The problem is most likely that you haven't set a max-age
or Expires
in the response.
Cache-Control: must-revalidate
tells clients that once this resource expires, they must revalidate it against the origin:
the cache MUST do an end-to-end revalidation every time, if, based solely on the origin server's Expires or max-age value, the cached response is stale
Since you don't declare when the page becomes stale, IE8 relies on heuristics to make an educated guess. If you want IE to revalidate the page every time, you need to add appropriate headers to keep the expiry short:
Cache-Control: private, must-revalidate, max-age=1
Expires: [immediately, or even a date in the past]
精彩评论