环境是wamp 2.2 64
首先要开启
LoadModule deflate_module modules/mod_deflate.so (压缩机制)
LoadModule headers_module modules/mod_headers.so (文件配置缓存的生存时间)
这两项服务。
我把配置文件放到了 .htaccess文件里
<ifmodule mod_deflate.c>
#启用对特定MIME类型内容的压缩
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|exe|t?gz|zip|bz2|sit|rar|pdf|mov|avi|mp3|mp4|rm)$ no-gzip dont-vary #设置不对压缩的文件
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-httpd-php application/x-javascript application/javascript #设置对压缩的文件
</ifmodule>
#文件缓存时间配置
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
以上配置直接复制即可使用!
可以使用 http://tool.chinaz.com/Gzips/ 来测试,查看效果!