Nginx-在缓存过期时使用proxy_cache_lock逻辑以避免多重请求

时间:2019-01-06 13:29:26

标签: nginx caching nginx-config

Proxy_cache_lock逻辑意味着NGINX同时接收到几个请求时,它仅发送一个上游,其余等待直到第一个返回并插入缓存(等待时间与{{ 1}})。

如果缓存元素已过期,并且proxy_cache_lock_timeout同时收到几个请求,则所有这些请求都将代理到上游。

问题:在缓存元素存在但已过期时,如何配置NGINXNGINX具有相同的逻辑?

我检查了proxy_cache_use_stale,但这不是我想要的,因为它在更新时返回了过期的缓存,我需要等待直到答案从上游返回...

这是我当前的proxy_cache_lock配置文件:

NGINX

我设法通过更改http { include /etc/nginx/mime.types; default_type application/octet-stream; access_log /var/log/nginx/access.log main; proxy_cache_path @MY_CACHE_PATH@; # this obviously has the path in my file proxy_cache_use_stale updating; proxy_cache_lock on; proxy_cache_lock_timeout 15s; proxy_cache_valid 404 10s; proxy_cache_valid 502 0s; proxy_cache one; server { listen 80; proxy_read_timeout 15s; proxy_connect_timeout 5s; include locations.conf; } } 源代码来实现此行为,但我想知道是否可以在配置中实现

0 个答案:

没有答案