apache 缓存模块配置

1、先检查是否有expires_module,方法mod_deflate.so一样

2、在配置文件中加入

#缓存7200000/3600/24=83天

<IfModule expires_module> 
    ExpiresActive on 
    ExpiresByType text/css A7200000
    ExpiresByType application/x-javascript A7200000
    ExpiresByType application/javascript A7200000
    ExpiresByType text/html A7200000
    ExpiresByType image/jpeg A7200000
    ExpiresByType image/gif A7200000
    ExpiresByType image/png A7200000
    ExpiresByType image/x-icon A7200000
</IfModule>
或者
<IfModule mod_expires.c>  
ExpiresActive On  
ExpiresByType text/css "now plus 1 month"  
ExpiresByType application/x-javascript "now plus 5 day"  
ExpiresByType image/jpeg "access plus 1 month"  
ExpiresByType image/gif "access plus 1 month"  
ExpiresByType image/bmp "access plus 1 month"  
ExpiresByType image/x-icon "access plus 1 month"  
ExpiresByType image/png "access plus 1 month"  
ExpiresByType application/x-shockwave-flash "access plus 1 month"  
</IfModule>  

3、检查图片是否已经缓存
[root@bogon conf]# curl -I http://192.168.2.195/DSC_7846.JPG
HTTP/1.1 200 OK
Date: Mon, 27 Feb 2017 10:28:36 GMT
Server: Apache/2.2.32 (Unix) DAV/2 PHP/5.5.38
Last-Modified: Thu, 02 Oct 2014 01:56:18 GMT
ETag: "c3aae-4e9903-50466ec1c3480"
Accept-Ranges: bytes
Content-Length: 5150979
Cache-Control: max-age=31104000
Expires: Thu, 22 Feb 2018 10:28:36 GMT  #图片缓存到的时间
Content-Type: image/jpeg

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值