参考页面: http://www.phpv.net/article.php/295
在linux下试验用mod_deflate模块来压缩网页以及静态文件等,经过试验发现例如prototype.js文件原来是47k大小,使用mod_deflate模块了大小不足11k,配置过程如下:
在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
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
# Header命令不对?注释这一行
# Header append Vary User-Agent env=!dont-vary
</Location>
重启apache即可生效。
心情: 一般