-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
Description
关键词
- expires/cache-control
- if-modified-since/if-none-match
- eTag
如何进行http缓存
304缓存
1.if-modified-since/Last-Modified
client request if-modified-since: time1
server response Last-Modified: time2
time1 = time2
2.if-none-match/ETag
client request if-modified-since: eTag1
server response ETag:eTag2
eTag1 = eTag2
200缓存
cache-control: max-age = 2592000 (s) (设置缓存时间)
expires: maybe next year
如何不进行http缓存
How to control web page caching, across all browsers?
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: 0
使用场景:隐私数据, api请求
QA
一. 200 OK (from cache) 与304 Not Modified 区别
200 (from cache)
- request status 为200的情况下并没有发起请求。根据
expires/cache-control判断。 - 回车访问
304
- 304的情况,http发起了请求。服务器响应。但是并不下载文件。根据
if-modified-since/if-none-match确认缓存文件是否存在。 - 强刷页面
结论:time 200快于304。
cache-control:max-age=0和no-cache的区别
no-cache no-store
- Why both no-cache and no-store should be used in HTTP response?
- Two Important Differences between Firefox and IE Caching
other
- if-modified-since if-none-match priority??
- if doc need cache ?? maybe no
- public && private , when to use ?