nginx静态资源设置缓存的方法

nginx静态资源设置缓存的方法

直接加expires 30d; 就是就可以了 缓存时间30天
完整如下

<pre>
location / {
root /home/www/wordpress;
index index.php index.html index.htm;
expires 30d;
if (!-e $request_filename) {
rewrite ^/p([0-9]*)/$ /?p=$1 last;
#rewrite /index.html /?p=967 redirect;
break;
}
}
</pre>
然后重新服务 nginx -s reload
然后测试 打开浏览器network
reponseheader里面
Cache-Control:max-age=2592000
30*24*3600=2592000秒

猜你喜欢

转载自www.cnblogs.com/newmiracle/p/11864736.html