配置Apache2启用mod_expires模块给文件添加Expires头

使用YSlow发现所在服务器上传输出来的文件Expires头都置为Expires: Thu, 19 Nov 1981 08:52:00 GMT了,非常奇怪的一个时间(莫非apache或者php某个开发人员是这个时候出生的),YSlow给出了加载expires模块的建议。

加载expires模块之后,编辑httpd.conf加入如下配置:

enable expirations

ExpiresActive On

expire GIF images after a day from the time they were accessed

ExpiresByType image/gif image/jpg A86400

HTML documents are good for a hour from the the time they were accessed

ExpiresByType text/html M3600

expire all default from the time they were accessed

ExpiresDefault “A7200”