Serve stale content if backend is healthy but "not too healthy"

Luca Gervasi luca.gervasi at
Tue Sep 21 13:32:05 UTC 2021

Hello everyone,

We have a backend that actually proxies different services (mangling
the original response). Sometimes one of those backends are not
available and the general response goes from 200 to a 50x.
Is there a way to serve a stale (valid) content (if present) for a
request that comes from a backend in a healthy state?

I was thinking about something like this:
sub backend_fetch {
  if (beresp.status >= 500) {

>From the state machine
( it seems
that I'm not allowed to return(hash) nor switch to an unhealthy
backend (that i keep configured) to reach what I want.

Please forgive me if do exists a facility to reach my goal and feel
free to direct me to the right document.

Ah. Varnish 6.x.


More information about the varnish-misc mailing list