Apache 配置静态缓存 加载mod_expires 模块的问题

回复 收藏
目的  缓存 网页  节约流量

配置步奏

1 修改虚拟机配置文件

  ExpiresActive on
  ExpiresByType image/gif   "access plus 1 days"
  ExpiresByType image/jpeg  "access plus 24 hours"
  ExpiresByType image/png   "access plus 24 hours"
  ExpiresByType text/css  "access plus 2 hours"
  ExpiresByType application/x-javascript  "now plus 2 hours"
  ExpiresByType application/x-shockwave-flash  "now plus 2 hours"
  ExpiresDefault "now plus 0 min"


2 重启apache   测试是否配置成功  


遇到问题   没有缓存时间的显示

[root@localhost local]# curl -x127.0.0.1:80 'http://www.yuq.com/static/image/common/logo_88_31.gif' -I
HTTP/1.1 200 OK
Date: Tue, 29 Dec 2015 08:43:43 GMT
Server: Apache/2.2.31 (Unix) PHP/5.6.16
Last-Modified: Tue, 08 Dec 2015 02:39:16 GMT
ETag: "a2470-9e0-52659e1375d00"
Accept-Ranges: bytes
Content-Length: 2528
Content-Type: image/gif


排障思路:缓存用到mod_expires 模块  那么先看自己的这个模块加载了没有
[root@localhost local]# apachectl -M     //发现没有加载

那么原因有两个

1 编译的时候 没有编译   排除

2 模块没有加载  

百度如何加载mod_expires 模块  

在Apache的httpd.conf文件中进行如下配置:
#启用expires_module模块
LoadModule expires_module modules/mod_expires.so      

修改后重启apache  排障碍成功


2015-12-29 17:01 举报
已邀请:

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: