1.浏览器的缓存策略
主要分为两种
强缓存
协商缓存
2.强缓存
如果存在cache-control:max-age 则直接走强缓存,http1.1 状态200(from cache)
一般会搭配 expires,但是优先级较低,可以不考虑 http1.0
3.协商缓存
如果存在缓存,则继续进行协商缓存。查看Etag和last-modified
etag会变成 if-none-match 发送服务器
last-modified 会变成if-modified-since 发送服务器
服务器确定是否命中。返回304或者200
etag优先级高于last-modified(存在只改时间不改内容的情况)
4.不走缓存
直接走200.
5.cache-control非强缓
public 针对CDN
private 针对CDN
no-cache
no-store
6.流程图综述
image.png
image.png













网友评论