浏览器缓存策略
强缓存
Http1.0
-
Pragma
-
使用Pragma:no-cache
Pragma只有一个值:no-cache,表示禁用缓存,要想启用缓存。就需要把Pragma首部字段删除
-
-
Expries
- 设置一个GMT时间来定义缓存过期时间
Http1.1
-
Cache-Control
- 启用缓存并定义缓存过期时间
协商缓存
Http1.0
- 无
Http1.1
-
Last-Modified
-
If-Modified-Since
- 如果修改时间匹配成功则返回304,否则服务器重发资源
-
If-Unmodified-Since
- 如果修改时间匹配成功则返回304,否则服务器返回412(不推荐使用,会返回4xx错误)
-
-
ETag
-
If-None-Match
- 如果etag标识匹配成功则返回304,否则服务器重发资源
-
If-Match
- 如果etag标识匹配成功则返回304,否则服务器返回412(不推荐使用,会返回4xx错误)
-
优先级
强缓存 > 协商缓存
Pragma > Cache-Control > Expires
ETag/If-None-Match > Last-Modified/If-Modified-Since
XMind - Trial Version