gpt4 book ai didi

http - Cache-Control 是 :must-revalidate obliging to validate all requests, 还是陈旧的?

转载 作者:可可西里 更新时间:2023-11-01 15:13:17 26 4
gpt4 key购买 nike

我对这个 header 一团糟,我读过 Cache-Control:must-revalidate 必须在提供缓存项之前使用源验证所有请求,但只是陈旧的?或者不管是陈旧的还是新鲜的?我在不同的地方读过这两本书。

Cache-Control:no-cache 有什么区别?因为这些 header 看起来和我一样。

更新 1:我从一本书中读到:

The Cache-Control: must-revalidate response header tells the cache to bypass the freshness calculation mechanisms and revalidate on every access:

@Peter O. 指出了 RFC 的内容。所以那本旧书是错的。

更新 2: 在本教程中:http://www.mnot.net/cache_docs/

no-cache — forces caches to submit the request to the origin server for validation before releasing a cached copy, every time. This is useful to assure that authentication is respected (in combination with public), or to maintain rigid freshness, without sacrificing all of the benefits of caching.

must-revalidate — tells caches that they must obey any freshness information you give them about a representation. HTTP allows caches to serve stale representations under special conditions; by specifying this header, you’re telling the cache that you want it to strictly follow your rules.

最佳答案

14.9.4 HTTP/1.1 的:

When the must-revalidate directive is present in a response received by a cache, that cache MUST NOT use the entry after it becomes stale to respond to a subsequent request without first revalidating it with the origin server

HTTP/1.1 的第 14.8 节:

If the response includes the "must-revalidate" cache-control directive, the cache MAY use that response in replying to a subsequent request. But if the response is stale, all caches MUST first revalidate it with the origin server...

所以看起来只有过时的响应必须重新验证,如果must-revalidate 已收到。

对于 no-cache,请参阅第 14.9.1 节:

If the no-cache directive does not specify a field-name [which is the case here], then a cache MUST NOT use the response to satisfy a subsequent request without successful revalidation with the origin server...

因此,no-cache 适用于新鲜和过时的响应。

编辑:

此短语可能与此处相关(第 13.3 节):

When a cache has a stale entry that it would like to use as a response to a client's request, it first has to check with the origin server (or possibly an intermediate cache with a fresh response) to see if its cached entry is still usable.

因此,must-revalidate 可能与缓存有中间值时相关缓存,否则缓存可以检查中间缓存新鲜响应而不是直接检查源服务器。

关于http - Cache-Control 是 :must-revalidate obliging to validate all requests, 还是陈旧的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7573466/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com