缓存控制:max-age=0 且重新验证值已过时?
如果 max-age
为零但 stale-while-revalidate
有值,会发生什么情况?
例如:Cache-Control: max-age=0, stale-while-revalidate=60
是否会考虑stale-while-revalidate
?或者每次获取数据都会命中原点?
what happens if the max-age
is zero but stale-while-revalidate
has a value?
example: Cache-Control: max-age=0, stale-while-revalidate=60
will the stale-while-revalidate
be taken into consideration at all? or the origin will be hit every time for the data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每次都会向源发送一个请求。
stale-while-revalidate
允许客户端使用过时的响应(当它通过源重新验证时)(如果响应的年龄小于max-age
+)重新验证时过时
。以下是使用 Cache-Control: max-age=0, stale-while-revalidate=60 的场景:
用户登陆页面,然后刷新页面。
响应立即过时,因为
max-age=0
但其age
在仍然可用的时间窗口内(即max-age + stale-while-revalidate< /代码>)。
客户端加载过时的响应并向源发送请求以重新验证它。
A request would be sent to the origin every time.
stale-while-revalidate
allows the client to use a stale response--while it revalidates with origin--if the response's age is less thanmax-age
+stale-while-revalidate
.Here's a scenario using
Cache-Control: max-age=0, stale-while-revalidate=60
:A user lands on a page and then refreshes the page.
The response is immediately stale because
max-age=0
but itsage
is within the still-usable window of time (i.emax-age + stale-while-revalidate
).The client loads the stale response and sends a request to the origin to revalidate it.