A stale-while-revalidate header the proxy actually honours

The directive is widely emitted and unevenly honoured, and nginx needs its own configuration rather than reading the response header.

# what the origin sends, for a CDN
add_header Cache-Control "public, s-maxage=3600,
    stale-while-revalidate=86400, stale-if-error=604800";

# what nginx itself needs, because it ignores the header
proxy_cache_use_stale updating error timeout http_500 http_502;
proxy_cache_background_update on;
proxy_cache_lock on;

proxy_cache_lock is the piece that prevents a stampede on expiry: without it, every request that arrives while an entry is being refreshed goes to the origin. With the background update and the lock together, one request refreshes and everybody else is served the stale copy, which is the behaviour the header was asking for.