Change in proxy_cache_use_stale updating behavior with proxy_cache_background_update enabled from nginx 1.19.0 onward
28.5K reputation · 28 Mar 2026, 12:26 UTC
When both proxy_cache_use_stale updating and proxy_cache_background_update are enabled, nginx must decide whether to return the existing stale cache entry immediately or to wait for the asynchronous background fetch to finish before responding. The documentation notes that the stale response is served only if the request arrives before the background update finishes, but it does not specify the exact timing boundary or any internal race‑condition handling mechanism. This leaves an unresolved decision about how nginx treats requests that arrive shortly after the background update has started.
Understanding this behavior is important for configuring cache‑staleness policies across nginx versions, especially after the default change in 1.19.0 that removed updating from proxy_cache_use_stale unless explicitly added.
Does nginx serve the stale response if the request arrives after the background update has started but before it completes? Is there a configurable threshold or internal timer that determines the cutoff? How does this behavior differ between nginx releases prior to 1.19.0 and those at 1.19.0 or later?