简体   繁体   English

Http缓存:缓存控制

[英]Http Caching : Cache-Control

I'm serving an image, with the header set in response as : 我正在提供图片,标题设置为:

Cache-Control : max-age=600000

As I understand, the image should now be treated as cache-able for the next 600000 seconds. 据我了解,该图像现在应被视为在接下来的600000秒内可缓存。 However i find Chrome constantly issuing a conditional request for the image every time i refresh the page using the last modified date : 但是我发现Chrome每次使用上次修改日期刷新页面时都会不断发出图像的条件请求:

If-Modified-Since: Thu, 19 Apr 2012 14:51:08 GMT

And since the image has not changed on the server, a 304 Not Modified response is issued. 并且由于映像在服务器上没有更改,因此发出304 Not Modified响应。

So my question is How do i prevent Chrome from issuing a conditional request all together? 所以我的问题是如何防止Chrome一起发出条件请求? when i directed that it's okay to cache the image for the next 600000 seconds, then why does it need to check with the server everytime? 当我指示可以在接下来的600000秒内缓存图像时,为什么它每次都需要与服务器进行检查? I would expect it to only check after 600000 seconds. 我希望它只能在600000秒后检查。

The reason why the browser was issuing a conditional request is because I was manually refreshing the browser. 浏览器发出条件请求的原因是因为我正在手动刷新浏览器。

When a user manually refreshes the page by clicking the refresh button (normal refresh), a conditional request is issued irrespective of the max-age. 当用户通过单击刷新按钮(正常刷新)手动刷新页面时,将发出有条件的请求,而与最大使用时间无关。

When a user Ctrl+clicks the refresh button (super refresh), an unconditional request is issued irrespective of the max-age. 当用户按住Ctrl +单击刷新按钮(超级刷新)时,将无条件地发出请求,而不考虑最大寿命。

Under normal navigation (clicking links) the browser won't issue any request when the max-age is valid. 在正常导航(单击链接)下,当max-age有效时,浏览器将不会发出任何请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM