Apache静态缓存配置

Apache配置静态缓存
[root@Linux9 logs]# apachectl -M     #查看expires_modul模块加载

expires_module (shared)     


[root@Linux9 logs]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf

以下为静态缓存配置:

 45 <IfModule mod_expires.c>
 46     ExpiresActive on
 47     ExpiresByType image/gif "access plus 1 days"
 48     ExpiresByType image/jpeg "access plus 24 hours"
 49     ExpiresByType image/png "access plus 24 hours"
 50     ExpiresByType test/css "now plus 2 hours"
 51     ExpiresByType application/x-javascripts "now plus 2 hours"
 52     ExpiresByType application/x-shockwave-flash "now plus 2 hours"
 53     ExpiresDefault "now plus 0 min"
 54 </IfModule>


[root@linux9 logs]# apachectl -t
Syntax OK

[root@linux9 logs]# apachectl graceful


注:ExpiresActive on       #缓存开关 启用或禁产生"Expires:"和"Cache-Control:"头的功能

      ExpiresDefault "now plus 0 min" #默认不缓存 设置了其作用范围内的所有文档的默认有效期的计算方法

修改ExpiresByType image/png "access plus 12 hours"

[root@Linux9 apache2]# vim conf/extra/httpd-vhosts.conf
[root@Linux9 apache2]# apachectl graceful
[root@Linux9 apache2]# curl -x192.168.25.57:80 'http://www.yh.com/static/image/common/logo.png' -I
HTTP/1.1 200 OK
Date: Thu, 07 Jan 2016 03:53:06 GMT
Server: Apache/2.4.17 (Unix) PHP/5.5.9
Last-Modified: Tue, 08 Dec 2015 02:39:16 GMT
ETag: "1149-52659e1375d00"
Accept-Ranges: bytes
Content-Length: 4425
Cache-Control: max-age=43200
Expires: Thu, 07 Jan 2016 15:53:06 GMT
Content-Type: image/png

如果修改:ExpiresByType image/gif "access plus 2 days"
Cache-Control: max-age=172800   两天时间
注:now和access,hour和hours都一样用!



本文转自 boy461205160 51CTO博客,原文链接:http://blog.51cto.com/461205160/1732469


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值