1
http {
    ...
    server {
        ...

        location /good { 
            proxy_cache mycache;
            proxy_cache_key $arg_cachekey;
            proxy_cache_valid 200 1h;
            proxy_cache_lock on;
            proxy_cache_lock_timeout 20m;
            proxy_cache_lock_age 20m;
            ...
            (upstream returning 200 with the content)
        }

        location /bad { 
            proxy_cache mycache;
            proxy_cache_key $arg_cachekey;
            proxy_cache_lock on;
            proxy_cache_lock_timeout 20m;
            proxy_cache_lock_age 20m;
            ...
            (upstream returning 404)
        }
    }
}

The cache is empty. Requesting:

GET /good?cachekey=123

after a short time while /good upstream is responding with the content, requesting:

GET /bad?cachekey=123

Should request on /bad location wait until /good retrieves cache and /bad respond with 200? If no, how to achieve it?

Jonas
  • 4,683
  • 4
  • 45
  • 81

0 Answers0