原创  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

发表于 @ 2009年01月01日 16:32:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:Linux修改SSH端口和禁止Root远程登陆设置  | 新一篇:在线图片处理网站

  • 发表评论
  • 评论内容:
  •  
Copyright © zhongmao
Powered by CSDN Blog