使用mod_deflate提升网页浏览的速度


apache1.3.x可以用mod_gzip进行优化网页浏览的速度,可以明显的感觉到速度的提升。在apache2中也尝试用mod_gzip,但是配置后确发现网页不能正确显示(空白页),所以改换mod_deflate。

在Linux命令行下运行以下命令安装mod_deflate模块(斜体是apache2的目录)

/usr/local/apache2/bin/apxs -i -c /root/httpd-2.0.48/modules/filters/mod_deflate.c

编辑httpd.conf,加入以下内容:

LoadModule deflate_module modules/mod_deflate.so

DeflateFilterNote ratio
LogFormat '"%v %h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" (%{ratio}n)' deflate


<Location />
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch /bMSIE !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI /.(?:gif|jpe?g|png)$ no-gzip dont-vary
#Header append Vary User-Agent env=!dont-vary
</Location>

#查找Customlog 注释原来的的一行,改成
CustomLog logs/deflate_log deflate

附注:关于mod_deflate的详细内容,可以参考http://httpd.apache.org/docs-2.0/mod/mod_deflate.html

你可能感兴趣的:(使用)