RFC 5861建议Cache-Control
扩展stale-while-revalidate
:
When present in an HTTP response, the stale-while-revalidate Cache- Control extension indicates that caches MAY serve the response in which it appears after it becomes stale, up to the indicated number of seconds.
The stale-if-error Cache-Control extension indicates that when an error is encountered, a cached stale response MAY be used to satisfy the request, regardless of other freshness information.
当无法重新验证响应时,允许过时的内容使用更长时间。
这些是supported by CDNs ,包括Fastly和 KeyCDN .
stale-while-revalidate
也是 mentioned in the Fetch standard (stale-if-error
不是)。
浏览器的支持状况如何?
最佳答案
截至2019年5月,根据Mozilla的兼容性表和 Chrome ,stale-while-revalidate
是:
这些将是 2019-07-09 上这些浏览器的主要版本和 2019-06-09分别。
stale-if-error
似乎没有当前或计划的支持。
(有关为什么在浏览器中实现此功能的更多详细信息,请参阅 RFC 作者的博客 Chrome and Stale-While-Revalidate。)
关于cross-browser - 哪些浏览器支持 stale-if-error 和 stale-while-revalidate?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56196238/