定义文档过期之前可以缓存的时间,优先级递减:
Cache-Control: no-store
Cache-Control: no-cache
Cache-Control: must-revalidate
Cache-Control: max-age
Expires
默认
1 no-store 与 no-cache
Pragma: no-cache
Cache-Control: no-store
Cache-Control: no-cache
no-store 禁止缓存,no-cache 可以存储在本地缓存中,但每次提供服务都必须进行再验证。
Pragma: no-cache 是为了兼容 HTTP1.0,相当于 Cache-Control: no-cache
2 max-age
Cache-Control: max-age=3600
Cache-Control: s-maxage=3600
表示文档处于新鲜状态的秒数
3 Expires
不推荐使用,因为很多服务器的时钟不同步或不正确。
Expires: Fri, 05 Jul 2002, 05:00:00 GMT
4 must-revalidate
Cache-Control: must-revalidate
可以配置缓存,使其提供一些过期的对象,来提高性能。如果原始服务器希望缓存严格遵守过期信息,可以使用这个响应头。
5 试探性过期
6 客户端的新鲜度限制
7 注意事项
网友评论