为什么在强缓存下响应码还是304

Recoding
  • 417
HTTP/1.1 200 OK
Server: Tengine
Content-Type: image/png
Content-Length: 4782
Connection: keep-alive
Date: Tue, 08 Aug 2017 03:16:05 GMT
Cache-Control: public,max-age=86400
Last-Modified: Fri, 09 Oct 2015 14:34:11 GMT
Accept-Ranges: bytes
ETag: "dd988e909f2d11:0"
Via: cache3.l2cm10[0,200-0,H], cache7.l2cm10[0,0], cache10.cn817[0,200-0,H], cache9.cn817[0,0]
Age: 2860283
X-Cache: HIT TCP_MEM_HIT dirn:2:3528722 mlen:-1
X-Swift-SaveTime: Mon, 04 Sep 2017 09:08:08 GMT
X-Swift-CacheTime: 31104000
Timing-Allow-Origin: *
EagleId: 75a9549d15050224484984567e

这是第一次请求的响应,Cache-Control指定了缓存过期倒计时。
按道理,这种情况是强缓存,会直接从内存中取出(在Chrom开发者工具中显示200 from cache)。但是结果
这是第二次请求的请求报文

GET /images/wechat.png HTTP/1.1
Host: common.cnblogs.com
Connection: keep-alive
If-None-Match: "dd988e909f2d11:0"
If-Modified-Since: Fri, 09 Oct 2015 14:34:11 GMT
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36
Accept: image/webp,image/apng,image/*,*/*;q=0.8
Referer: http://www.cnblogs.com/wonyun/p/5524617.html
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.8
Cookie: pgv_pvi=2361670656; UM_distinctid=15c062221f6184-04407bf9cabcdd-51472a15-100200-15c062221f7113; __gads=ID=6277b8c32053dfce:T=1495275629:S=ALNI_MZEN1kgU8-m1ubHN5EYUgGQ33P-2Q; __utma=226521935.2014282979.1494496904.1503279125.1503281996.12; __utmz=226521935.1503281997.12.10.utmcsr=baidu|utmccn=(organic)|utmcmd=organic; _ga=GA1.2.2014282979.1494496904; pgv_si=s8048331776

响应

HTTP/1.1 304 Not Modified
Server: Tengine
Content-Type: image/png
Connection: keep-alive
Date: Tue, 08 Aug 2017 03:16:05 GMT
Cache-Control: public,max-age=86400
Last-Modified: Fri, 09 Oct 2015 14:34:11 GMT
Accept-Ranges: bytes
ETag: "dd988e909f2d11:0"
Via: cache3.l2cm10[0,200-0,H], cache7.l2cm10[0,0], cache10.cn817[0,304-0,H], cache6.cn817[0,0]
Age: 2860463
X-Cache: HIT TCP_IMS_HIT dirn:2:3528722 mlen:-1
Timing-Allow-Origin: *
EagleId: 75a9549a15050226282975794e
回复
阅读 2.4k
1 个回答

第二次请求,浏览器发送
If-Modified-Since: Fri, 09 Oct 2015 14:34:11 GMT
服务器发现客户端是最新的
所以就返回304 not modified,这个逻辑是没有问题的呀。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
你知道吗?

宣传栏