### activate mod_expires
ExpiresActive On
### Expire .gif's 1 month from when they're accessed
ExpiresByType image/gif "access plus 3 months"
ExpiresByType image/png "access plus 3 months"
ExpiresByType image/jpg "access plus 3 months"
ExpiresByType text/javascript "access plus 3 months"
使用Chrome审核工具和YSlow Firebug工具,看起来这样可以缓存我的一些图片/文件,但目前还没有。我还有一个文件列表(.jpg,.js和.css - 我知道我没有设置要缓存的css文件),这些文件不是缓存的。 Chrome审核中的消息只会指出The following resources are missing a cache expiration. Resources that do not specify an expiration may not be cached by browsers:
一些不缓存的图像是背景图像,其他图像是js图库的一部分,它们是通过JS调用的 - 这可能会影响它们不缓存的原因吗?
很抱歉,我无法提供代码链接 - 这些网站仍然处于封装状态,仅限于客户端视图。
提前致谢!
答案 0 :(得分:9)
看起来你写错了MIME类型:
# enable expirations
ExpiresActive On
ExpiresDefault "access plus 1 week"
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
ExpiresByType image/pjpeg "access plus 1 week"
ExpiresByType text/javascript "modification plus 1 week"
ExpiresByType application/javascript "modification plus 1 week"
ExpiresByType text/css "modification plus 1 week"