.htaccess - htaccess 'Header unset Last-Modified' 缓存问题

标签 .htaccess caching last-modified

我试图在我的 htaccess 文件中设置一些缓存控制选项。

目前它看起来像这样:

<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>

但是我读到(并想添加)Header unset Last-Modified,所以它会是这样的:
<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>

但是,使用它(根据 Firebug)根本不会从缓存中加载任何内容(而第一种技术会加载所有内容)

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

一种。

最佳答案

语法正确,但用法不对。
根据此处找到的“速度提示:删除上次修改的标题”:http://www.askapache.com/htaccess/apache-speed-last-modified.html

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!



还:

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!!



有关更多详细信息,请参阅原始链接。

关于.htaccess - htaccess 'Header unset Last-Modified' 缓存问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2546711/

相关文章:

java - 如何将上次修改日期与文件上次修改日期进行比较?

retrofit - 在 okhttp 中,我想处理 Last-Modified 和 ETags,但不缓存整个响应

regex - (递归).htaccess 文件的正则表达式

php - 当我将 URL 作为参数传递时 Apache 失败

jquery - FullCalendar "view"可缓存

java堆内存问题

android - 带有大图像的 ListView 非常慢

.htaccess - 如何使用 htaccess 将域重定向到子域?

.htaccess - 仅通过 HTTP 访问网站,除了 2 个页面

java - 如何在 Java 中获取具有最新 lastModified 日期的文件?