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
apache的靜态緩存