Stale Cache Update Timing with proxy_cache_background_update
25.5K reputation · 10 Nov 2023, 07:59 UTC
The goal is to determine when nginx replaces a stale cache entry after a background refresh initiated by proxy_cache_background_update.
Documentation specifies that stale content can be served while a background subrequest updates the cache, but it does not clarify whether the updated object overwrites the stale entry immediately upon completion of the background fetch or only after the original entry’s TTL expires. This ambiguity affects expectations about cache freshness under concurrent requests.
Does nginx overwrite the stale entry as soon as the background subrequest finishes, regardless of the original TTL? If the original TTL has not yet expired, does nginx retain the stale object until that TTL elapses before considering the update? Is there any existing configuration that controls this replacement timing?