网页减肥-apache中启用gzip压缩

先启用 LoadModule deflate_module modules/mod_deflate.so,只需要把前面的#去掉就可以了。

然后在httpd.conf最下面添加以下行:

DeflateBufferSize 8096
DeflateCompressionLevel 1
DeflateMemLevel 9
DeflateWindowSize 15

DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
DeflateFilterNote ratio
LogFormat ‘”%r” %{outstream}n/%{instream}n (%{ratio}n%%)’ deflate
CustomLog logs/deflate.log deflate

<Location />
SetOutputFilter DEFLATE

AddOutputFilterByType DEFLATE text/html text/css application/x-javascript text/plain text/xml
</Location>

然后重启apache,即可。可以用firefox的插件yslow来查看效果,此时会看到”Compress components with gzip”项的等级为A,说明配置成功了.