<div dir="ltr"><div dir="ltr">Hi,</div><div dir="ltr"><br></div><div dir="ltr">As Dridi said, what you are looking for is exactly vmod_stale, but I wanted to point out that part:</div><div dir="ltr"><br></div><div dir="ltr">> We have a backend that actually proxies different services</div><div dir="ltr"><br></div><div dir="ltr">In that case, it might be good to actually have a Varnish backend for each type of backend behind the proxies. The backend definition would be exactly the same, but the probe definitions would be different, with a specific URL/host. this way, Varnish would be aware of who is actually unhealthy and you don't have to deal with the stale thing.</div><div dir="ltr"><br></div><div dir="ltr">If you need an open-source approach, I reckon the best you can do is restart with a zero TTL if you detect a bad response. It does have a couple of race conditions baked-in that vmod_stale sidesteps, but that's usually good enough:</div><div dir="ltr"><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="monospace">sub vcl_recv {</font></div><div><font face="monospace">    # be hopeful that the backend will send us something good, ignore grace</font></div><div><font face="monospace">    if (req.restarts == 0) {</font></div><div><font face="monospace">        set req.grace = 0s;</font></div><div><font face="monospace">    }</font></div><div><font face="monospace">}</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">sub vcl_deliver {</font></div><div><font face="monospace">    # welp, that didn't go well, try again without limiting the grace</font></div><div><font face="monospace">    if (req.restarts == 0 && resp.status >= 500) {</font></div><div><font face="monospace">        set req.ttl = 10y;</font></div><div><font face="monospace">        return (restart);</font></div><div><font face="monospace">    }</font></div><div><font face="monospace">}</font></div></blockquote><div dir="ltr"><br></div><div dir="ltr">Main issue is that you restart, so you are going to spend a lil bit more time/resources processing the request, and the object in cache may have expired by the time you realize you need it.</div><div dir="ltr"><br></div><div dir="ltr">Hope that helps,<br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>-- <br></div><div>Guillaume Quintard</div></div></div></div></div></div>