Difference between no-cache and must-revalidate

前端 未结 4 947
时光说笑
时光说笑 2020-11-28 17:50

From the RFC 2616

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.1

no-cache

If the no-cache directive does not spe

相关标签:
4条回答
  • 2020-11-28 18:32

    I think there is a difference between max-age=0, must-revalidate and no-cache:

    In the must-revalidate case the client is allowed to send a If-Modified-Since request and serve the response from cache if 304 Not Modified is returned.

    In the no-cache case, the client must not cache the response, so should not use If-Modified-Since.

    0 讨论(0)
  • 2020-11-28 18:37

    I believe that must-revalidate means :

    Once the cache expires, refuse to return stale responses to the user even if they say that stale responses are acceptable.

    Whereas no-cache implies :

    must-revalidate plus the fact the response becomes stale right away.

    If a response is cacheable for 10 seconds, then must-revalidate kicks in after 10 seconds, whereas no-cache implies must-revalidate after 0 seconds.

    At least, that's my interpretation.

    0 讨论(0)
  • 2020-11-28 18:37

    max-age=0, must-revalidate and no-cache aren't exactly identical. With must-revalidate, if the server doesn't respond to a revalidation request, the browser/proxy is supposed to return a 504 error. With no-cache, it would just show the cached content, which would be probably preferred by the user (better to have something stale than nothing at all). This is why must-revalidate is intended for critical transactions only.

    0 讨论(0)
  • 2020-11-28 18:39

    With Jeffrey Fox's interpretation about no-cache, i've tested under chrome 52.0.2743.116 m, the result shows that no-cache has the same behavior as must-revalidate, they all will NOT use local cache when server is unreachable, and, they all will use cache while tap browser's Back/Forward button when server is unreachable. As above, i think max-age=0, must-revalidate is identical to no-cache, at least in implementation.

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