xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

浏览器 HTTP Cache 缓存的存储位置、优先级、条件、机制、原理是什么 All In One

浏览器 HTTP Cache 缓存的存储位置、优先级、条件、机制、原理是什么 All In One

  1. memory cache
  2. disk cache

浏览器缓存

HTTP cache 存储位置、优先级、条件、 机制、原理是什么?

from memory cache
from disk cache

🕵️‍♂️这块内容,目前看来没有比较正确的答案呀

image

image

现在我是这么理解的 ✅

  1. 首先所有的资源第一次加载后,都是存在 memory cache 里面的;浏览器然后,根据 http cache 策略(强缓存/协商缓存),判断某个资源是否要 写入 disk cache;
  2. 后面,刷新页面再次请求资源的时候,浏览器按照(暂不考虑 service worker 等其他缓存)memory cache > disk cache 的顺序依次查找资源,直到命中,或重新请求;

The cache from which the request got matched can have an impact on the way this request is represented in DevTools and Resource Timing.

匹配请求的缓存可能会影响此请求在 DevTools 和 Resource Timing 中的表示方式。

https://calendar.perfplanet.com/2016/a-tale-of-four-caches/

强缓存 & 协商缓存

强缓存:

  • expires
  • Cache-Control

协商缓存:

  • ETag / If-None-Match
  • Last-Modified / If-Modified-Since

demos

https://cdn.xgqfrms.xyz/

https://cdn.xgqfrms.xyz/http-cache/index.html

image

image

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

refs



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2020-05-19 19:24  xgqfrms  阅读(959)  评论(5编辑  收藏  举报