What's the difference between Cache-Control: max-age=0 and no-cache?

后端 未结 9 2003
小蘑菇
小蘑菇 2020-11-22 09:32

The header Cache-Control: max-age=0 implies that the content is considered stale (and must be re-fetched) immediately, which is in effect the same thing as

9条回答
  •  眼角桃花
    2020-11-22 10:01

    max-age
        When an intermediate cache is forced, by means of a max-age=0 directive, to revalidate 
    its own cache entry, and the client has supplied its own validator in the request, the 
    supplied validator might differ from the validator currently stored with the cache entry. 
    In this case, the cache MAY use either validator in making its own request without 
    affecting semantic transparency. 
    
        However, the choice of validator might affect performance. The best approach is for the 
    intermediate cache to use its own validator when making its request. If the server replies 
    with 304 (Not Modified), then the cache can return its now validated copy to the client 
    with a 200 (OK) response. If the server replies with a new entity and cache validator, 
    however, the intermediate cache can compare the returned validator with the one provided in 
    the client's request, using the strong comparison function. If the client's validator is 
    equal to the origin server's, then the intermediate cache simply returns 304 (Not 
    Modified). Otherwise, it returns the new entity with a 200 (OK) response. 
    
        If a request includes the no-cache directive, it SHOULD NOT include min-fresh, 
    max-stale, or max-age. 
    

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

    Don't accept this as answer - I will have to read it to understand the true usage of it :)

提交回复
热议问题