ubuntu apache mod_expires模块

ubuntu 下mod_expires是安装好的,开启就可以了

1
2
3
sudo a2enmod headers
sudo a2enmod expires
sudo /etc/init.d/apache2 restart在httpd.conf中添加

<IfModule mod_expires.c>
# turn on the module for this directory
ExpiresActive on

# cache common graphics for 3 days
ExpiresByType image/jpg "access plus 3 days"
ExpiresByType image/gif "access plus 3 days"
ExpiresByType image/jpeg "access plus 3 days"
ExpiresByType image/png "access plus 3 days"

# cache CSS for 24 hours
ExpiresByType text/css "access plus 24 hours"

# set the default to 24 hours
ExpiresDefault "access plus 24 hours"
</IfModule>

All that was left was to restart Apache and test everything.

/<your path>/apache2/bin/apachectl configtest
/<your path>/apache2/bin/apachectl restart

Testing was simple. I tailed the access log and made two requests for the same page. The first request resulted with a flurry of files being requested (all the graphics being downloaded). The second request resulted in a single file request (no graphics) and the graphics where logged as HTTP status 304 (unmodified), success.

 

apache中如果需要关闭不用的模块,则使用 a2dismod 命令

 重新加载配置文件:

root@ubuntu:~# sudo /etc/init.d/apache2 force-reload

 

參考:

http://www.electrictoolbox.com/apache-mod-expires-browser-caching/

http://blog.csdn.net/fafa211/article/details/5515457

http://www.360doc.com/content/08/0626/16/36491_1373009.shtml

http://blog.chedushi.com/archives/3868

http://www.geekwisdom.com/dyn/cache-control2

 

posted @   feiling  阅读(495)  评论(0编辑  收藏  举报
编辑推荐:
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
· 一次Java后端服务间歇性响应慢的问题排查记录
阅读排行:
· 互联网不景气了那就玩玩嵌入式吧,用纯.NET开发并制作一个智能桌面机器人(四):结合BotSharp
· Vite CVE-2025-30208 安全漏洞
· 《HelloGitHub》第 108 期
· MQ 如何保证数据一致性?
· 一个基于 .NET 开源免费的异地组网和内网穿透工具
点击右上角即可分享
微信分享提示