htaccess的“头未设置的Last-Modified”缓存问题 [英] htaccess 'Header unset Last-Modified' caching issue

查看:407
本文介绍了htaccess的“头未设置的Last-Modified”缓存问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林试图建立在我的htaccess文件中的一些缓存控制选项。

Im trying to set up some cache control options in my htaccess file.

目前,它看起来是这样的:

At the moment it looks like this:

<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf|css|js|html|pdf)$">
Header set Cache-Control "max-age=2592000, public, must-revalidate"
Header unset ETag
FileETag None
</FilesMatch>

不过我也读到了(并希望添加)头取消设置的Last-Modified,所以这将是这样的:

However I read about (and wanted to add) Header unset Last-Modified, so it would be something like:

<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf|css|js|html|pdf)$">
Header set Cache-Control "max-age=2592000, public, must-revalidate"
Header unset Last-Modified
Header unset ETag
FileETag None
</FilesMatch>

然而,使用这种(根据萤火虫)犯规做出任何负载从缓存中的所有(而第一种技术加载所有内容)

However, using this (according to Firebug) doesnt make anything load from the cache at all (whereas the first technique loads everything)

我是不是做错了什么?语法似乎是正确的。

Am I doing something wrong? The syntax seems to be right.

一个。

推荐答案

的语法是正确的,但用法不。 据超速提示:删除Last-Modified头在这里找到: HTTP: //www.askapache.com/htaccess/apache-speed-last-modified.html

The syntax is correct, but the usage isn't. According to "Speed Tips: Remove Last-Modified Header" found here: http://www.askapache.com/htaccess/apache-speed-last-modified.html

如果您删除的Last-Modified和ETag头,你会完全消除的If-Modified-Since和If-无 - 匹配请求及其304未修改响应,这样的文件将保持不检查更新直到过期缓存头指示新的内容可用!

If you remove the Last-Modified and ETag header, you will totally eliminate If-Modified-Since and If-None-Match requests and their 304 Not Modified Responses, so a file will stay cached without checking for updates until the Expires header indicates new content is available!

另外:

通过消除双方的ETag头和上次修改的报头的静态文件(图片,JavaScript,CSS)的浏览器和缓存将不能够验证文件的缓存版本与真实版。通过还包括一个Cache-Control头和Expires头,你可以指定某些文件被缓存的一段时间,你奇迹般地(这是一个非常独特的把戏我保证)消除任何验证请求!

By removing both the ETag header and the Last-Modified headers from your static files (images, javascript, css) browsers and caches will not be able to validate the cached version of the file vs. the real version. By also including a Cache-Control header and Expires header, you can specify that certain files be cached for a certain period of time, and you magically (this is a really unique trick I promise) eliminate any validation requests!!

参考原文链接查看更多细节。

Refer to the original link for more details.

这篇关于htaccess的“头未设置的Last-Modified”缓存问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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