windows下apache开启gzip压缩 加快网页下载速度

针对windows版本的apache2.2,开启方法如下:
第一步:
找到apache的配置文件httpd.conf,找到下面两行,将前面的 # 去掉.

Html代码 复制代码
  1. LoadModule deflate_module modules/mod_deflate.so   
  2. LoadModule expires_module modules/mod_expires.so  
LoadModule deflate_module modules/mod_deflate.so
LoadModule expires_module modules/mod_expires.so


重启apache服务器.
第二步:
打开网站的 .htaccess 文件,将下面代码拷贝进去:

Html代码 复制代码
  1. <IfModule mod_expires.c>  
  2. ExpiresActive On   
  3. ExpiresDefault "access plus 12 month"   
  4. ExpiresByType text/html "access plus 12 months"   
  5. ExpiresByType text/css "access plus 12 months"   
  6. ExpiresByType image/gif "access plus 12 months"   
  7. ExpiresByType image/jpeg "access plus 12 months"   
  8. ExpiresByType image/jpg "access plus 12 months"   
  9. ExpiresByType image/png "access plus 12 months"   
  10. EXpiresByType application/x-shockwave-flash "access plus 12 months"   
  11. EXpiresByType application/x-javascript      "access plus 12 months"   
  12. ExpiresByType video/x-flv "access plus 12 months"   
  13. </IfModule>  
  14.   
  15. <IfModule mod_deflate.c>  
  16. SetOutputFilter DEFLATE   
  17. AddOutputFilterByType DEFLATE text/html text/css image/gif image/jpeg image/png application/x-javascript   
  18. </IfModule>  

代码没错,测试通过了的,大家可以放心使用.

效果如下:
网址 http://www.k686.com/ 检测结果如下:
是否压缩 是
压缩类型 gzip
原始文件大小 91844 字节
压缩后文件大小 15365 字节
压缩率(估计值) 83.27%


Header信息
Date Thu, 03 Jun 2010 09:00:14 GMT
Server Apache/2.2.11 (Win32) PHP/5.2.10
X-Powered-By PHP/5.2.10
Set-Cookie PHPSESSID=nkcqphhqt8005prgnn35fdfif4; path=/
Expires Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control private
Pragma no-cache
Vary Accept-Encoding
Content-Encoding gzip
Content-Length 15365
Keep-Alive timeout=5, max=100
Connection Keep-Alive
Content-Type text/html; charset=utf-8

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值