Apache配置静态缓存

配置好之后,访客可以申请缓存加快再次访问的时间,配置代码如下:

vim /usr/local/apache2/conf/extra/httpd-vhosts.conf

<IfModule mod_rewrite.c>模块上面添加如下信息:

<IfModule mod_expires.c>

          ExpiresActive on

          ExpiresByType image/gif "access plus 1 days"

          ExpiresByType image/jpeg "access plus 24 hours"

          ExpiresByType image/png "access plus 24 hours"

          ExpiresByType text/css "now plus 2 hours"

          ExpiresByType application/x-javascript "now plus 2 hours"

          ExpiresByType application/x-shockwave-flash "now plus 2 hours"

          ExpiresDefault "now plus 0 min"

</IfModule> 

保存退出

apachectl -t

apachectl graceful


测试配置:

curl -x127.0.0.1:80 'http://www.test.com/static/image/common/logo.png'  -I


你可能感兴趣的:(静态,缓存)