使用 Apache 控制缓存的正确方法是什么?
所以我在这里有一个小网站,我的用户每天都会访问并使用它,偶尔他们只是希望我对一个只有(最多)512 字节文本的文件进行一些小的更改。
现在,当他们使用 IE8 或 IE9 时,他们的浏览器保留了旧的缓存,并且不会更新,除非后台出现严重的痛苦,使他们不得不敲击 f5 或其他东西来清除缓存。
显然这是我的网络服务器的错误,因为我没有正确处理我的缓存控制标头,但我对标头不够熟悉,不知道它是什么。
以下是我要发送的内容(于 2011 年 5 月 20 日 15:12:26 GMT
):
Response Headers
Connection:Keep-Alive
Date:Fri, 20 May 2011 19:12:26 GMT
ETag:"8001e-310f-4a3b8f421ac00"
Keep-Alive:timeout=15, max=100
Server:Apache/2.2.12 (Ubuntu)
Vary:Accept-Encoding
我需要发送什么来修复我的缓存控制,以便为我的 IE 用户更新缓存(仅当文件实际上已被修改)?在 Chrome 中运行良好。
So I've got a small site here where my users come to and use it daily, and once in a while they just want me to make some small changes to a file that will only be about (at most) 512bytes of text.
Now, when they use IE8 or IE9, their browser kept an old cache, and won't update without being a serious pain in the backside making them have to hammer on f5 or something else to clear the cache.
Obviously this is my web server's fault in the fact I'm not doing something properly with my cache control headers, but I'm not familiar enough with the headers to know what it is.
Here's what I'm sending (at 20 May 2011 15:12:26 GMT
):
Response Headers
Connection:Keep-Alive
Date:Fri, 20 May 2011 19:12:26 GMT
ETag:"8001e-310f-4a3b8f421ac00"
Keep-Alive:timeout=15, max=100
Server:Apache/2.2.12 (Ubuntu)
Vary:Accept-Encoding
What do I need to send to fix my cache control so the cache updates for my IE users (only when the file has actually been modified)? Works fine in Chrome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用
Last-Modified
和Expires
标头。如果不出意外,Expires 标头将被视为强烈暗示,表明在该日期/时间过后应获取新副本。try the
Last-Modified
andExpires
headers. If nothing else, the Expires header would be taken as a strong hint that a fresh copy should be fetched after that date/time is passed.