HTTP“过期”标题在Chrome中不起作用 [英] HTTP "Expires" header does not work in Chrome

查看:194
本文介绍了HTTP“过期”标题在Chrome中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的系统是Windows 7 x64,Chrome 20.0.1132.57米。

在我的HTTP响应标题中,我有:

  Cache-Control:public,max-age = 1000 
过期日期:*某日期*

在IE& FF,页面缓存在本地,当我尝试通过输入URL并按回车再次访问时,不发送请求并且页面显示正确。但在Chrome中,它始终使用以下标头向服务器发送请求:

  Cache-Control:max-age = 0 

我不希望客户端向我的服务器发送请求,然后回复304.我想保存往返时间。

解决方案

当您测试时请小心。我注意到,在Chrome版本20中,如果我点击F5重新加载页面,那么在网络面板中,我会看到新的请求。
如果我将光标放在标题栏上,在当前页面的url之后,并回车,我就会从缓存中获取资源,并将头部设置为缓存。



另外它最好使用最大年龄。 Max age和Expires是相同的,但在最大年龄你指定的持续时间。



看到这个:
http://betterexplained.com/articles/how-to-optimize-your-site-with-http-caching/
方法3和方法4.

My system is Windows 7 x64, Chrome 20.0.1132.57 m.

In my HTTP response header, I have:

Cache-Control: public, max-age=1000
Expires: *some date*

In IE & FF, the page is cached in local, and when I try to access again by typing the URL and hit enter, no request is send and the page is displayed correctly. But in Chrome, it always send a request to the server with the following header:

Cache-Control: max-age=0

I do not want the client send a request to my server and then reply 304. I want to save the round-trip time.

解决方案

Be carefull when you are testing. I noticed that in Chrome version 20 if I hit F5 to reload the page then in the network panel I see new requests. Hoewer if I place the cursor to the title bar, after the current page url, and hit enter, I get resources from cache, whitch header was set to cache.

Also its better just use the max age. Max age and Expires is the same, but in max age you specify the duration.

See this: http://betterexplained.com/articles/how-to-optimize-your-site-with-http-caching/ Method 3 and Method 4.

这篇关于HTTP“过期”标题在Chrome中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆