We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
HTTP响应头中的Cache-Control和Expires都是用于控制缓存有效期的,当两者同时存在且产生冲突时,Cache-Control的优先级更高。原因在于Expires通过设定具体的时间戳来定义缓存有效期,这在客户端和服务端时间不一致的情况下会造成问题。可参考MDN上的描述:
如果还有一个 设置了 "max-age" 或者 "s-max-age" 指令的Cache-Control响应头,那么 Expires 头就会被忽略。
而Last-Modified响应头只有当缓存失效时才会发挥作用,严格意义上来说,与Cache-Control和Expires之间不存在“优先级”的关系。当缓存失效时,浏览器会在HTTP请求中添加If-Modified-Since头,其值即为之前Last-Modified响应头的值,服务器则会根据文件的更新情况选择返回304或者200。
在HTTP请求头中,也可以用Cache-Control来控制对缓存的使用,从“控制缓存行为”的角度上看,这种请求头中的Cache-Control的“优先级”比响应头中的Cache-Control还要高。
原文链接:https://www.zhihu.com/question/64343325/answer/230293665
Sorry, something went wrong.
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: