-
Notifications
You must be signed in to change notification settings - Fork 0
HTTP Cache
2012 edited this page Jul 20, 2020
·
2 revisions
作为响应首部字段返回,表示资源的一个绝对过期时间。不可靠,因为两边时间不一定同步。
Expires: Wed, 21 Oct 2015 07:28:00 GMT
,如果时间无效,则表示已过期。
当与 Cache-Control 同时存在时,Expires 则会被忽略,优先使用 Cache-Control
指令不区分大小写,多个指令以逗号分隔。
指令 | 报文类型 | 描述 |
---|---|---|
no-store | request | 不缓存资源 |
no-cache | request | 未成功验证前,不能使用缓存副本 |
max-age | request | 未过期前,可以直接使用缓存副本 |
max-stale | request | 未超过指定的时间内,愿意使用过期副本 |
min-fresh | request | 不能小于这个指定的时间与它的当前存活时间之和,即在指定的时间内,缓存副本还是新鲜的 |
no-transform | request | 资源在发送之前不允许被转换 |
only-if-cached | request | 只有当资源在缓存中才发送,不要联系原始服务器 |
public | response | 资源可以被任何服务器缓存 |
private | response | 资源只能被单个客户端缓存使用 |
no-store | response | 不缓存资源 |
no-cache | response | 未成功验证前,不能使用缓存副本 |
no-transform | response | 资源在发送之前不允许被转换 |
must-revalidate | response | 缓存副本使用前,必须要重新向服务器验证 |
proxy-revalidate | response | 同 must-revalidate,除了私有缓存 |
max-age | response | 指定时间内,保持资源的新鲜度 |
s-maxage | response | 在共享缓存中,覆盖 max-age 和 Expires 指定的指令。私有缓存无效 |
弱检验码和强校验码,弱校验码不一定能唯一标志资源的一个实例,弱校验码有可能校验的是资源的字节大小、最后修改时间在容差范围内;而强校验码则不管关联的实体发生了什么性质的变化。 If-None-Match 使用弱比较与 Etag 比较
表示资源最后一次修改的时间,没有 Etag 优先级高。如果 If-None-Match 存在,则忽略 If-Modified-Since。如果 If-Match 存在,则忽略 If-Unmodified-Since
由于 Cache-Control 是 HTTP/1.1 才有的,Pragma 是为了与 HTTP/1.0 兼容而存在的一个首部字段,可以指定 no-cache 指令。当 Cache-Control 存在时,会忽略 Pragma
资源参考
JS
CSS
- float
- BFC
- position
- flex
- grid
DOM
- DOM
- how browser works
Node.js
react
- 生命周期
- setState
- hook
git
- git 基础命令
- git rebase 理解
- git bisect
- git commit
- git hook
设计模式
- 策略模式
- ...
TCP/IP 协议
- HTTP/1.x
- HTTP/2
- SSL/TLS
- TCP
- DNS
- HTTP Cache
- CORS
- http status code
linux(shell)知识点