Actions after cache miss is detected
Maxim Dounin
mdounin at mdounin.ru
Sun Aug 12 21:26:05 UTC 2018
Hello!
On Fri, Aug 10, 2018 at 09:05:30AM -0700, Roger Fischer wrote:
> Is there a way to perform an action after a cache miss is
> detected but before the request is forwarded to the upstream
> server?
>
> Specifically, on a cache miss I want to:
> Return a response instead of forwarding the request to the
> upstream server.
> Trigger a handler (module or script) that executes
> asynchronously to the request.
>
> The latter I could do by looking at the logs. But I was
> wondering if there is a more elegant way.
There is no direct way to do this. There are multiple of ways to
do this indirectly though, including:
- configure a backend which returns a non-cacheable response and
triggers appropriate actions;
- configure a non-responding backend and error_page 502 to return
a response and trigger appropriate processing.
Alternatively, in some cases it might be more convenient to use
proxy_store instead of proxy_cache, and then work with responses
on the file system - with try_files and so on.
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx
mailing list