问题
The Etag provided cache validation that works well with FF & chrome, but IE seems to ignore the Etag value and always returns the cached response.
The server response is:
HTTP/1.1 200 OK
Date: Mon, 07 Jul 2014 06:01:57 GMT
Content-Type: application/json
ETag: a7628382056ddd13b7e06991571fd3ad
Content-Encoding: gzip
Content-Length: 4360
when client sends a conditional get request
If-None-Match: 71fb49ecd6f85545693dec0e78ae2131
The request is not sent at all and IE returns the cached response. It transparent when ETag value is the same but a problem when ETag is different.
The only solution that worked for me was adding header
Cache-Control: no-cache
I monitored the network and it forces IE to validate the ETag value.
problem is solved!
However I didn't find any official solution for this problem. I used the post Make IE to cache resources but always revalidate as a reference but most of the information was irrelevant to my problem.
if you have another idea or advise please share
回答1:
Internet Explorer uses some heuristics for caching responses. You can read more at Caching Improvements in Internet Explorer 9 in the Heuristic Cache Improvements section:
If a Last-Modified header wasn’t present in the server’s response, then Internet Explorer will fall back to the “Once per browser session” revalidation behavior.
and:
if the response does have a Last-Modified time, the heuristic expiration value SHOULD be no more than some fraction of the interval since that time. A typical setting of this fraction might be 10%.
What you want is to bypass these heuristics and force IE to revalidate the content with the server. To do so, please check Make IE to cache resources but always revalidate and its answer. The key headers seem to be:
Last-Modified: Wed, 16 Feb 2011 13:52:26 GMT
Expires: -1
Cache-Control: must-revalidate, private
Bonus: please also see the section about the Vary Improvements in the earlier link:
If a response contains a Vary directive that specifies a header other than Accept-Encoding, Host, or User-Agent (or any combination of these) then Internet Explorer will still cache the response if the response contains an ETAG header. However, that response will be treated as stale and a conditional HTTP request will be made before reuse to determine if the cached copy is valid.
While it does not say what happens when no Vary
header specified, it might be worth playing with this value (see this post)
来源:https://stackoverflow.com/questions/24604921/ie-9-ignores-etag-value-change-and-returns-cached-response