dWi*_*der 8 caching nginx nginx-config
Proxy_cache_lock逻辑意味着当NGINX同时接收到几个请求时,它只向上游发送一个,其余的等待第一个返回并插入缓存(等待时间如配置中所述proxy_cache_lock_timeout)。
如果缓存元素过期,并且NGINX同时接收到几个请求,它们都会被代理到上游。
问题:当缓存元素存在但已过期时,我如何将其配置NGINX为具有相同的逻辑proxy_cache_lock?
我检查了proxy_cache_use_stale但这不是我要找的,因为它在更新时返回过期的缓存,我需要等到答案从上游返回......
这是我当前的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;
}
}
Run Code Online (Sandbox Code Playgroud)
我通过更改NGINX源代码设法实现了这种行为,但我想知道是否可以在配置中实现