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秒

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM