1、作用
成都创新互联是一家专注于成都做网站、网站设计与策划设计,回民网站建设哪家好?成都创新互联做网站,专注于网站建设十余年,网设计领域的专业建站公司;建站业务涵盖:回民等地区。回民做网站价格咨询:18982081108
节约带宽,额外消耗CPU;部分老浏览器不支持;
压缩适于压缩的资源,例如文本文件;
2、涉及模块
LoadModule deflate_module modules/mod_deflate.so(CentOS6默认启用)
3、配置(httpd-2.2)
~]# vim /etc/httpd/conf.d/mod_deflate.conf
输入以下代码
SetOutputFilter DEFLATE # 设置压缩过滤器,指明哪些类型适合压缩 # mod_deflate configuration # Restrict compression to these MIME types 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 # Level of compression(Highest 9 - Lowest 1) DeflateCompressionLevel 6 # 压缩级别根据CPU消耗和带宽来决定,6为默认 # Netscape 4.x has some problems... BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.06-4.08 have some more problems BrowserMatch ^Mozilla/4\.0[678] no-gzip # MSIE masquerades as Netscape, but it is fine BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
~]# httpd -t ~]# service httpd reload
4、确认压缩效果
配置前
配置后