YSlow页面优化

开启Apache的mod_expires模块,在httpd.conf最后面加上以下代码(一个月后失效)。

  1. < IfModule  mod_expires.c >
  2.      < FilesMatch  "/.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$" >
  3.        ExpiresActive on
  4.        ExpiresDefault "access plus 1 month"
  5.      </ filesmatch >
  6. </ IfModule >

linux下安装
要支持DSO动态模块加载
安装mod_expires
cd httpd-2.2.6/modules/metadata/
/usr/local/apache/bin/apxs -c -i -a mod_expires.c

在httpd.conf中添加

ExpiresActive on
ExpiresDefault “access plus 12 month”
ExpiresByType text/html “access plus 12 months”
ExpiresByType text/css “access plus 12 months”
ExpiresByType image/gif “access plus 12 months”
ExpiresByType image/jpeg “access plus 12 months”
ExpiresByType image/jpg “access plus 12 months”
ExpiresByType image/png “access plus 12 months”
EXpiresByType application/x-shockwave-flash “access plus 12 months”
EXpiresByType application/x-javascript “access plus 12 months”
ExpiresByType video/x-flv “access plus 12 months”

windows 打开httpd.ini 找到
#LoadModule expires_module modules/mod_expires.so
取掉#号
再加上面那一段代码

重起apache,效果很明显示,apache 内存占用量下去了很多,带宽用量也少了很多~

在httpd.conf最后面加上以下代码(使用最后修改时间和文件大小作为etag)

  1. #This bit of code instructs Apache to send along an Etag value 
  2. #that is calculated by combining the modification time 
  3. #and file size of the file being transmitted.
  4. FileETag MTime Size

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值