A #devops question: is there a way to set up a "rolling cache" with nginx?

I want it to handle each request like so:

1. Immediately respond with the cached version
2. Start rebuilding the cache for that request in the background, so the next request for this URI gets a newer cached version

Cc @rysiek

Follow

@kuba @rysiek

Nie also that rysiek enabled proxy_cache_lock. I expect that without that your desired configuration would send one backend request per incoming request.

@robryk @kuba yup. There's a bunch of hard earned knowledge in that config. That's to some extent the config that got a OCCRP through the Panama Papers traffic spike. :blobcatgiggle:

Another non-obvious thing: remember to cache your 404 and other errors. Otherwise your backend might be accidentally brought down by some random typo in a link somewhere. :blobcatsweat:

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.