1.配置静态缓存
#vim /usr/local/apache2/etc/httpd.conf
#开启mod_expires模块
LoadModule expires_module modules/mod_expires.so #去掉注释
#添加:
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/gif "access plus 1 days"
ExpiresByType image/jpeg "access plus 24 hours"
ExpiresByType image/jpg "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/javascript "now plus 2 hours"
ExpiresByType application/x-shockwave-flash "now plus 2 hours"
ExpiresDefault "now plus 0 min"
</IfModule>
2.检查配置文件语法并重启apache
apachectl -t
apachectl restart
3.验证:
curl -x10.0.0.101:80 'http://10.0.0.101/a.jpg' -I