linux nginx http cache时间不对,Linux中Nginx设置proxy_cache缓存与取消缓存-linux-操作系统-壹...
本文章來講述一下關于Linux中Nginx設置proxy_cache緩存與取消緩存實現方法,有需要的朋友可參考。
在配置文件的server{}內,添加這么一句即可:
代碼如下
復制代碼
location ~ .*/.(css|js)$ {
add_header Cache-Control 'no-store';
}
在nginx.conf里的http塊加入以下代碼
#proxy_temp_path和proxy_cache_path指定的路徑必須在同一分區
proxy_temp_path?? /tmp/proxy_temp_dir;
#設置名稱為nginx_cache,內存緩存空間大小為500MB,30天沒有被訪問的內容自動清除,硬盤緩存空間大小為30GB。
proxy_cache_path? /tmp/proxy_cache_dir? levels=1:2?? keys_zone=nginx_cache:200m inactive=3d max_size=30g;
在server加入以下代碼
代碼如下
復制代碼
location / {
proxy_cache nginx_cache;
proxy_cache_key $host$uri$is_args$args;
proxy_set_header Host? $host;
proxy_set_header X-Forwarded-For? $remote_addr;
expires? 30d;
}
重啟Ngnix
代碼如下
復制代碼
/usr/local/nginx/sbin/nginx -s reload
總結
以上是生活随笔為你收集整理的linux nginx http cache时间不对,Linux中Nginx设置proxy_cache缓存与取消缓存-linux-操作系统-壹...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android socket 框架c#,
- 下一篇: 达梦数据库导入oracle数据_达梦数据