Proxy_cache_lock logic means that when NGINX
receives couple of request simultaneously, it sends only one upstream and the rest waiting till the first one returns and insert to cache (wait time is as configure in proxy_cache_lock_timeout
).
If the cache element expired, and the NGINX
receives couple of request simultaneously all of them are proxied to the upstream.
Question: How can I configure the NGINX
to have the same logic as proxy_cache_lock
also when the cache element exist but expired?
I checked proxy_cache_use_stale but it is not what I'm looking for because its return the expired cache when updating and I need to wait till the answer return from upstream...
This is my current NGINX
configuration file:
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;
}
}
I managed to achieve this behavior by changing the NGINX
source code but I wonder if that can be achieve within configuration