我见过Apache htaccess文件代码的例子,其中压缩在缓存之前,而visa则相反。哪一个是正确的?我经常使用redbot.org,在缓存产生的问题较少的情况下,它似乎是压缩的。
发布于 2015-10-18 11:06:34
你可以这样用gzip压缩:
<ifModule mod_deflate.c>
<filesMatch ".(css|js|x?html?|php)$">
SetOutputFilter DEFLATE
</filesMatch>
</ifModule>要缓存文件,您可以执行以下操作:
<ifModule mod_headers.c>
<filesMatch ".(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
<filesMatch ".(css)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
<filesMatch ".(js)$">
Header set Cache-Control "max-age=216000, private"
</filesMatch>
<filesMatch ".(x?html?|php)$">
Header set Cache-Control "max-age=600, private, must-revalidate"
</filesMatch>
</ifModule>欲了解更多信息,请访问以下页面:http://samaxes.com/2009/01/more-on-compressing-and-caching-your-site-with-htaccess/
https://stackoverflow.com/questions/33193858
复制相似问题