IE 9+ ignores ETag value change and returns cached response

前端 未结 1 1737
Happy的楠姐
Happy的楠姐 2021-02-14 01:10

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 respons

1条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-14 01:38

    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)

    0 讨论(0)
提交回复
热议问题