apache 配置静态元素过期时间
修改虚拟主机配置文件
vim /usr/local/apache/conf/extra/httpd-vhosts.conf
# 基于动态库mod_expires.c 保证编译时存在(service httpd -M)
<VirtualHost *:80>
...
...
<IFModule mod_expires.c>
ExpiresActive on #功能启动
ExpiresByType image/gif "access plus 1 days" #gif图片,缓存1天
ExpiresByType image/jpeg "access plus 2 days" #jpeg图,缓存2天
ExpiresByType image/png "access plus 24 hours" #png图,缓存24小时
ExpiresByType text/css "now plus 2 hours"
ExpiresByType applicantion/x-javascript "now plus 2 hours"
ExpiresByType applicantion/x-shockwave-flash "now plus 2 hours"
ExpiresDefault "now plus 0 min"
</IfModule>
</VirtualHost>
重新加载配置文件
# 检查配置文件
/usr/local/apache2/bin/apachectl –t
# 重新加载配置文件
/usr/local/apache2/bin/apachectl graceful
最后更新于
这有帮助吗?