我安装的是apache2.0.64,这个版本的apche默认编译了expires模块,在httpd.conf里有
LoadModule expires_module modules/mod_expires.so
这 一行,但是没有<IfModule mod_expires.c>的相关配置,所以需要在httpd.conf中添加, 添加在LoadModule这一句之后的任何位置都行,下面的配置中将过期时间统一设置为访问时间加12个月,可以自行更改为想要的:
<IfModule mod_expires.c>
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"
</IfModule>
转自 http://www.51testing.com/?uid-314542-action-viewspace-itemid-804869