您的位置:首页 > 理论基础 > 计算机网络

如何在Apache HTTP Server中配置mod_deflate?

2011-04-15 23:35 597 查看
首先加载module

LoadModule deflate_module modules/mod_deflate.so

在apache中的配置方法:

<IfModule deflate_module>

<Location />

  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

</Location>

  # 声明输入流的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

</IfModule>

也可以做如下简单配置:

<IfModule deflate_module>

  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

</IfModule>

在IBM HTTP Server中可采用如下配置:

<Location />

  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-vary

</Location>

DeflateCompressionLevel 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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  apache server output byte exe