在apache1.3,大家常用mod-gzip对输出内容进行压缩,现在主流的浏览器都支持gzip解压缩,这样可以大大减轻网络流量。
在apache2下,这个模块换*为mod_deflate,在debian下如下配置,来打开deflate
在debian下,把apache2的设置文件分成了多个小文件,模块的调入和配置放在
/etc/apache2/mods-available目录下,要调入mod_deflate模块,只要做*个符号连接:
ln -s /etc/apache2/mods-available/deflate.load /etc/apache2/mods-enabled/deflate.load
然后建立配置文件/etc/apache2/mods-available/deflate.conf 同样做符号连接
ln -s /etc/apache2/mods-available/deflate.conf /etc/apache2/mods-enabled/deflate.conf
设置文件只包含*行,对3种文件输出进行压缩
AddOutputFilterByType DEFLATE text/html text/plain text/xml
然后重新启动apache2:
/etc/init.d/apache2 reload
下面是压缩前后,apache的日志,可以看出流量减小了差不多5倍
192.168.2.12 - - [01/Mar/2005:10:22:19 +0800] "GET /net/client/member.php HTTP/1.1" 200 39784 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)"
192.168.2.12 - - [01/Mar/2005:10:23:29 +0800] "GET /net/client/member.php HTTP/1.1" 200 39784 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)"
192.168.2.12 - - [01/Mar/2005:10:27:32 +0800] "GET /net/client/member.php HTTP/1.1" 200 8177 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)"
192.168.2.12 - - [01/Mar/2005:10:27:57 +0800] "GET /net/client/member.php HTTP/1.1" 200 8195 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)"