-
Notifications
You must be signed in to change notification settings - Fork 510
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
【Q079】简述 http 的缓存机制 #80
Comments
强缓存 协商缓存 |
Http 缓存分为以下两种,两者都是通过 HTTP 响应头控制缓存
强制缓存再次请求时无需再向服务器发送请求 client server
GET /a.ab389z.js ------->
<------- 200 OK
(再也不会发请求) 与之相关的 Response Headers 有以下几个
协商缓存再次请求时,需要向服务器校验新鲜度,如果资源是新鲜的,返回 304,从浏览器获取资源 client server
GET /a.js ----------->
<----------- 200 OK
GET /a.js ----------->
<----------- 304 Not Modified 与之相关的 Request/Response Headers 有以下几个
|
今天在看这个问题的时候,发现一个关于强制缓存的意外情况。在刷新页面时,有的浏览器会重新验证缓存资源的新鲜度,有的不会。 假设第一次请求资源的Response Heades包含下列强制缓存信息
在有效期内,按照强制缓存的概念解释,再次请求资源时,不会发送请求,直接返回200。 在stackoverflow找到了一些关于这个问题的回答https://stackoverflow.com/questions/45829055/why-doesnt-chrome-re-validate-in-memory-cache-when-doing-a-normal-reload/57281076#57281076 |
No description provided.
The text was updated successfully, but these errors were encountered: