修改Nginx配置文件,定义对静态页面的缓存时间
proxy ]# vim /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
expires 30d; //定义客户端缓存时间为30天
}
}
proxy ]# cp /usr/share/backgrounds/day.jpg /usr/local/nginx/html /拷贝一个jpg文件到网页目录
proxy ]# /usr/local/nginx/sbin/nginx -s reload
# firefox http://192.168.4.5/day.jpg //优化后,使用Firefox浏览器访问图片,查看缓存信息
结束.