我很想实现浏览器缓存并遵循 Google PageSpeed 关于将 Last-Modified 设置为“过去足够远”的数据的建议。我的 .htaccess 中有以下内容:
<IfModule mod_headers.c>
<FilesMatch "\.(json|pdf|swf|bmp|gif|jpeg|jpg|png|svg|tiff|ico|flv|js)$">
Header Set Last-Modified "Fri, 01 Jan 2010 12:00:00 GMT"
</FilesMatch>
</IfModule>
我的服务器上安装了 mod_headers。
不幸的是,Google PageSpeed 仍然抱怨并警告我:
Leverage browser caching
The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:
然后列出 PNG、GIF、JPG 等。Yahoo YSlow 说的基本相同。
查看我应该缓存的资源之一的响应标头,我看到了:
Date: Tue, 19 Oct 2010 20:12:04 GMT
Server: Apache/2.2.14 (Ubuntu)
Last-Modified: Tue, 07 Sep 2010 23:51:33 GMT
Etag: "2e0e34-2a43-48fb413a96a20"
Accept-Ranges: bytes
Content-Length: 10819
Content-Type: image/png
如您所见,Last-Modified 数据与我在 .htaccess 中指定的数据不匹配。
任何想法我做错了什么?