D
D
DefaultX2019-10-02 23:25:46
Nginx
DefaultX, 2019-10-02 23:25:46

How does proxy_cache_lock work in nginx?

Hello!
I'm trying to set up caching on nginx, it is necessary that if the cache is missing or updated , one request is sent to the backend, for this, as I understand it, you need to use the proxy_cache_lock directive, but if there is no cache, initially with a large number of requests, they are not blocked but go to the backend. What have I done wrong ?

proxy_cache_valid 200 1m;
    
proxy_cache_use_stale updating;
proxy_cache_background_update on;
proxy_cache_lock on;

proxy_cache_path /var/local/nginx/cache levels=1:2 inactive=12h keys_zone=cache:10m max_size=500m use_temp_path=off;
proxy_cache_key $http_host$request_uri;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DefaultX, 2019-10-03
@DefaultX

The problem is solved by simply adding the proxy_cache_lock_timeout directive
proxy_cache_lock_timeout 60s;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question