如果我将服务器响应设置为:Cache-Control: private,no-cache,max-age=900
?
如果标题是这样的,会发生什么:Cache-Control: public,no-cache,max-age=900
?
因为它有一个 no-cache
浏览器(或代理服务器)是否考虑max-age
?
最佳答案
如 RFC documents 中所述:
If the no-cache directive does not specify a field-name, then a cache MUST NOT use the response to satisfy a subsequent request without successful revalidation with the origin server. This allows an origin server to prevent caching even by caches that have been configured to return stale responses to client requests.
结果,如果
no-cache
已在服务器的响应中定义,这意味着浏览器(和任何中间缓存)将在每个请求上“重新验证”(也就是向源服务器发出请求并返回其响应,而不是使用任何缓存内容)。所以,要清楚地回答你的问题:
Since it has a no-cache whether browser (Or proxy server) consider the max-age?
不,浏览器不会考虑
max-age
(鉴于浏览器可以处理 no-cache
指令,因为某些 HTTP 1.0 浏览器/缓存可能无法识别此指令)。
关于caching - 如果 Cache-Control 有 `no-cache` 和 `max-age=900` 会发生什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50039634/