1

Nginx proxy_cache_valid

 1 year ago
source link: https://fann.im/blog/2014/12/09/nginx-proxy_cache_valid/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Nginx proxy_cache_valid

Dec 9, 2014

proxy_cache 可以缓存 upstream 响应,其中 proxy_cache_valid 设置缓存有效时间,需要注意的是 Nginx 检查缓存是否有效的优先级问题。根据文档Igor,Nginx 判断缓存有效的顺序是:

  1. X-Accel-Expires
  2. Expires/Cache-Control
  3. proxy_cache_valid

也就是说 Nginx 会优先用 upstream 设置的缓存有效期,这种情况下 Nginx 相当于 Client,如果想忽略缓存直接到 upstream 更新,类似浏览器忽略本地缓存,可以这样设置:

proxy_ignore_headers X-Accel-Expires Expires Cache-Control;

另外 proxy_cache_path ... inactive=10m; 不受 upstream 影响,缓存文件在指定时间内没有被再次访问会被清理删除。

Was this page helpful?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK