nginx subrequests / background operations

Ameir Abdeldayem ameirh at
Fri Jun 6 04:57:38 UTC 2014


I am investigating the complexity of allowing for an additional parameter,
"expired", to proxy_cache_use_stale.

Instead of a request hitting the backend with an $upstream_cache_status of
EXPIRED and making the client wait for the request to complete, the client
would instead be given a stale version of that cached entry, and that entry
would be updated in the background.

The directive would look like:
proxy_cache_use_stale expired updating error ...;

I was looking into ngx_http_subrequest() as a potential route to take, but
it looks like it's blocking (as in the client would have to wait for it to
complete).  I also looked at post_action, but it's unclear on whether it's
blocking or not, and whether it'd work for this case.

Could you advise me on the best route to take here?

Varnish 4 supports this feature ("grace mode") and I'm getting some
pressure to switch solely because of this feature, but because I love nginx
so much, I figured I'd take a stab at getting this feature in.

Any tips would be well-appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx-devel mailing list