Rails 请问 CDN 来的图片,是通过哪个 header 来缓存的?

happyming9527 · October 21, 2017 · Last by weibo17534017 replied at May 09, 2018 · 1653 hits

如上图,图片的地址是 cdn 的地址,response 中没有 expires,cache-control 这样的控制缓存的字段。 请问浏览器为啥会从 disk cache 中读取缓存?

有 etag 和 last-modified

Reply to quakewang

etag 和 last-modified 是用来做 conditional HTTP GET 的吧。控制缓存,不是应该用 expires 和 cache-control 么?

自己回答一下吧。查了一下,应答如果没有 expires 或者 cache-control 的 header,浏览器也会默认给予缓存。规则基本上都是(date - last modify)/10,不过这个是依赖浏览器的行为,并不可靠。

happyming9527 closed this topic. 24 Oct 19:05
happyming9527 reopened this topic. 24 Oct 19:05

CDN 缓存,其实这些限止都是可以取消掉了,强制缓存

expires cache-control

You need to Sign in before reply, if you don't have an account, please Sign up first.