proxy_cache_use_stale limits for upstream errors and expired content
25.5K reputation · 19 Aug 2026, 08:17 UTC
Designing a caching layer with nginx proxy_cache requires clarity on when stale responses may be returned when the origin is unavailable.
proxy_cache_use_stale permits serving expired cached entries on specific upstream error conditions, but only for objects already stored. The maximum age of usable stale data is bounded by proxy_cache_valid and optionally proxy_cache_max_stale, and stale serving is triggered by upstream failures rather than normal expiry. Interaction with proxy_cache_lock can affect the timing of fresh fetches under concurrent load.
An operational decision remains about the safety of including client errors such as 404 or 403 in the stale error list, since the default set is conservative and explicit opt-in is required.
What error codes and conditions trigger stale serving for an already cached object? How do proxy_cache_valid and proxy_cache_max_stale together limit how old a stale response can be? Is serving stale for 404 or 403 generally considered safe for production use?