mod_deflate模块

mod_deflate模块

压缩模块,使用mod_deflate模块压缩页面优化传输速度
主要是需要设置
1.针对的内容
2.压缩比是多少
可以忽略排除特定旧版本的浏览器的设置。因为那些都太老了,现在一般遇不到了

适用场景:

(1) 节约带宽,额外消耗CPU;同时,可能有些较老浏览器不支持

(2) 压缩适于压缩的资源,例如文本文件

Level of compression (Highest 9 - Lowest 1) 表示对于数据所做的压缩等级,数字最大,压缩越好

curl 访问的话,不加选项,默认是不压缩的

指定压缩比,数值越大,压缩越好
DeflateCompressionLevel 9

指定需要压缩的资源
AddOutputFilterByType DEFLATE text/plain

使用案例
vim /etc/httpd/conf.d/test.conf

DeflateCompressionLevel 5
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/css

排除特定旧版本的浏览器,不支持压缩 (可以忽略,因为都是上古浏览器)

  • Netscape 4.x 只压缩text/html
  • BrowserMatch ^Mozilla/4 gzip-only-text/html
  • Netscape 4.06-08三个版本 不压缩
  • BrowserMatch ^Mozilla/4.0[678] no-gzip
  • Internet Explorer标识本身为“Mozilla / 4”,但实际上是能够处理请求的压缩。如果用户代理首部匹配字符串“MSIE”(“B”为单词边界”),就关闭之前定义的限制
  • BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

猜你喜欢

转载自www.cnblogs.com/ddz-linux/p/10699402.html
mod