apache配置expires_module缓存静态文件

本文详细介绍了如何在Apache 2.2.14版本中修改httpd.conf文件,通过启用资源缓存功能,将静态资源的访问时间缩短至两天,并特别针对Shockwave Flash文件延长至三天,从而显著提升网站加载速度。
Apache版本apache_2.2.14-win32-x86-openssl-0.9.8k.msi

修改httpd.conf文件:
1,去掉#LoadModule expires_module modules/mod_expires.so这行前面的#号

2,增加如下配置

<IfModule expires_module>
ExpiresActive On
ExpiresDefault "access plus 2 days"
ExpiresByType application/x-shockwave-flash "access plus 3 days"
</IfModule>


restart apache服务器就生效了
通过httpwatch观察http请求Headers Received:
Expires已经是两天后了


(Status-Line) HTTP/1.1 200 OK
Accept-Ranges bytes
Cache-Control max-age=172800
Connection Keep-Alive
Content-Length 561276
Content-Type image/jpeg
Date Fri, 18 Nov 2011 02:18:18 GMT
ETag "2000000010a90-8907c-46ea3c3de04ac"
Expires Sun, 20 Nov 2011 02:18:18 GMT
Keep-Alive timeout=5, max=99
Last-Modified Tue, 14 Jul 2009 05:32:31 GMT
Server Apache/2.2.14 (Win32)
# LAMP Auto Install Script for CentOS 7 #centos7下编写自动化脚本搭建lamp架构,下载目录为/opt/lamp1/,需求版本:apache-2.4.63、php-7.4.33、mysql-8.0.41-1.el9.x86_64.rpm-bundle.tar,php不用单独启动,和apache联动即可 #要求: #安装apache和php的依赖模块apr-1.7.5、apr-util-1.6.3、ibiconv-1.15、libmcrypt-2.5.8、mhash-0.9.9.9、mcrypt-2.6.8、libmcrypt-devel并做好环境变量和软连接 #apache开启模块如下模块并解决依赖问题{ core_module (static) so_module (static) http_module (static) mpm_prefork_module (static) authn_file_module (shared) authn_core_module (shared) authz_host_module (shared) authz_groupfile_module (shared) authz_user_module (shared) authz_core_module (shared) access_compat_module (shared) auth_basic_module (shared) socache_shmcb_module (shared) socache_dbm_module (shared) reqtimeout_module (shared) filter_module (shared) mime_module (shared) log_config_module (shared) env_module (shared) expires_module (shared) headers_module (shared) setenvif_module (shared) version_module (shared) ssl_module (shared) unixd_module (shared) status_module (shared) autoindex_module (shared) dir_module (shared) alias_module (shared) rewrite_module (shared) php5_module (shared) proxy_module (shared) proxy_ajp_module (shared) proxy_balancer_module (shared) proxy_connect_module (shared) proxy_http_module (shared) slotmem_shm_module (shared)} #php开启模块如下模块并解决依赖问题{bcmath bz2 Core ctype curl date dom ereg fileinfo filter gd gettext hash iconv json libxml mbstring mcrypt mhash mysql mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar posix Reflection session shmop SimpleXML soap sockets SPL sqlite3 standard sysvmsg sysvsem sysvshm tokenizer xml xmlreader xmlwriter zip zlib} #验证apache和php联动访问,MySQL登录和初始化、密码设置为1hblsqt2zhlmcl#@!
03-11
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值