cache2-stale-while-revalidate interaction with worker process restarts
0 reputation · 02 Oct 2023, 09:23 UTC
uwsgi cache2 provides per-process key-value storage with a documented 'expires' parameter for time-bound entries; absent an explicit setting, items persist until the hosting worker process restarts. Version 2.0.10 added the 'cache2-stale-while-revalidate' flag to control stale entry serving during background revalidation, but how this flag interacts with worker process restarts across a deployment remains unspecified.
Because each uwsgi worker process maintains its own independent cache2 instance, stale entry behavior is not shared or synchronized between workers unless an external store such as Redis is deployed. The undocumented interaction between cache2-stale-while-revalidate and per-process restart cycles raises questions about whether stale serving resets, persists, or becomes inconsistent depending on which worker handles a given request.
- Does the cache2-stale-while-revalidate window reset to zero when a worker process restarts, or does it retain a relative timeout from the original entry insertion?
- When multiple worker processes serve requests for the same application, can stale entries be served inconsistently depending on which worker handles the request, and if so, what configuration mitigates this without resorting to an external cache?
- How does the cache2-stale-while-revalidate behavior differ between uwsgi 1.9.x and 2.0.x, given the documented version-dependent variance?