1.配置nginx的缓存
一般我们需要缓存的内容有:图片、css、js等,主要针对的是图片的缓存
#查看一般的缓存时间
修改缓存时间
server{
......
location ~* \.(jpg|png|jpeg|bmp|gif|swf|ico|txt|css|js)$ {
root /usr/local/nginx/html/Cartoon-Page;
expires 30d;
}
......
}
#检查nginx配置
nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
#重启nginx
nginx -s reload
2.在浏览器中查看缓存的过期时间