如何在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
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
相关文章推荐
- python3.x配置Apache http server(完成和mod_python相同的功能)
- 利用 mod_jk 整合 Apache HTTP Server 与 Tomcat 配置(linux)
- 第一季:Tomcat 8迷情】 第7集 apache http server+tomcat+mod_jk在linux上的负载均衡配置
- apache中有virtual host如何配置mod_jk
- 使用mod_cluster进行apache httpd server和jboss eap 6.1集群配置
- Win10下配置Apache Http Server与连接CGI
- Windows 下 Apache HTTP Server 安装、配置以及与 Tomcat 的整合(附图)
- 在apache http server中配置虚拟机和虚拟路径的方法
- Apache HTTP Server 2.0 安装和配置
- windows 下的apache http server 配置
- Linux下安装Apache Http Server 的配置+一些错误信息的解决方法
- Ubuntu server 11.04 下配置Apache的Worker模式+mod_fcgid+APC
- Ubuntu server 11.04 下配置Apache的Worker模式+mod_fcgid+APC
- 使用rpm格式安装并配置httpd(Apache HTTP Server)
- 为OTA部署配置Apache http server
- Apache HttpServer 虚拟目录配置
- CentOS7安装配置Apache HTTP Server
- 解决 win7 64位旗舰版 php 5.4 与 apache 2.4 正确配置 httpd.conf 文件,apache http server 2.4 不能启动
- Windows 下 Apache HTTP Server 安装、配置以及与 Tomcat 的整合(附图)
- Apache HTTP Server mod_dav.c 拒绝服务漏洞(CVE-2013-1896)