Apache HTTP Server:如何配置mod_deflate?
首先加载module
LoadModule deflate_module modules/mod_deflate.so
在apache中的配置方法:
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4/.0[678] no-gzip
BrowserMatch /bMSI[E] !no-gzip !gzip-only-text/html
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
SetEnvIfNoCase Request_URI /.(?:gif|jpg|cab|jpe?g|exe|bmp|mp3|rar|zip|swf|png)$ no-gzip dont-vary
Header append Vary User-Agent
# 声明输入流的byte数量
DeflateFilterNote Input instream
# 声明输出流的byte数量
DeflateFilterNote Output outstream
# 声明压缩的百分比
DeflateFilterNote Ratio ratio
# 声明日志类型
LogFormat ‘%t “%r” %{outstream}n/%{instream}n (%{ratio}n%%)’ deflate
CustomLog logs/deflate_log deflate
也可以做如下简单配置
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
SetEnvIfNoCase Request_URI /.(?:gif|jpg|cab|jpe?g|exe|bmp|mp3|rar|zip|swf|png)$ no-gzip dont-vary
# 声明输入流的byte数量
DeflateFilterNote Input instream
# 声明输出流的byte数量
DeflateFilterNote Output outstream
# 声明压缩的百分比
DeflateFilterNote Ratio ratio
# 声明日志类型
LogFormat ‘“%r” %{outstream}n/%{instream}n (%{ratio}n%%)’ deflate
CustomLog logs/deflate_log deflate
在IBM HTTP Server中可采用如下配置
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
SetEnvIf User-Agent ^Mozilla/4 gzip-only-text/html
SetEnvIf User-Agent ^Mozilla/4/.0[678] no-gzip
SetEnvIf User-Agent /bMSIE !no-gzip
SetEnvIf User-Agent /bMSIE !gzip-only-text/html
SetEnvIfNoCase Request_URI /.(gif|jpg|cab|jpe?g|exe|bmp|mp3|rar|zip|swf|png)$ no-gzip dont-varyDeflateCompressionLevel 9
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio# %h host, %t time, %r request url
LogFormat ‘“%h %l %u %t %r” %{outstream}n/%{instream}n (%{ratio}n%%)’ deflate
CustomLog logs/deflate_log deflate
还没有评论,来说两句吧...