登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

SeaRiver Blog

实力才是你一生最好的依靠!

 
 
 

日志

 
 

配置Apache2启用deflate压缩加快传输  

2008-08-19 13:02:38|  分类: apache |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |


下载了Yahoo的给Firefox开发的YSlow插件,这个插件确实不错,能够给出不少优化建议,发现所在主机没有开启deflate压缩。
首先加载mod_deflate。
在httpd.conf中加入

<Location />

# Insert filter
SetOutputFilter DEFLATE

# 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

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don't compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|exe|bmp|mp3|rar|zip|swf|cab|t?gz|bz2|sit)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

</Location>

再重启apache即可,/etc/init.d/apache2 restart
经过port80software的在线检测,首页大小从91977 bytes压缩到13376 bytes,传输速度提高6.8X,传输速度从原来12.832 s缩减到1.866 s。
如果修改配置之后提示“Invalid command 'Header', perhaps mis-spelled or defined by a module not included in the server configuration”,则加载Header模块即可,不过最好还是在编译apache模块时直接加上--enable-deflate --enable-headers就省事多了。

 

 

  评论这张
 
阅读(715)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018