Skip to content
New issue

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

【Q206】no-cache 与 no-store 的区别是什么 #207

Open
shfshanyue opened this issue Feb 26, 2020 · 2 comments
Open

【Q206】no-cache 与 no-store 的区别是什么 #207

shfshanyue opened this issue Feb 26, 2020 · 2 comments
Labels

Comments

@shfshanyue
Copy link
Owner

No description provided.

@lijiayi01
Copy link

no-cache 可以在本地缓存,可以在代理服务器缓存,但是这个缓存要服务器验证才可以使用
no-store 是禁用缓冲,本地和代理服务器都不缓冲,每次都从服务器获取

@shfshanyue
Copy link
Owner Author

no-cacheno-store 用作控制缓存,被服务器通过响应头 Cache-Control 传递给客户端

no-store

永远都不要在客户端存储资源,每次永远都要从原始服务器获取资源

no-cache

可以在客户端存储资源,但每次都必须去服务器做新鲜度校验,来决定从服务器获取最新资源 (200) 还是从客户端读取缓存 (304),即所谓的协商缓存

当服务器资源返回 304 时与那些 HTTP 响应头有关

一般情况下对于 index.html 或者现代构建环境下不加 hash 的静态资源都需要设置 Cache-Control: no-cache,用来强制每次在服务器端的新鲜度校验。

相当于以下响应头

Cache-Control: max-age=0, must-revalidate

相关问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants