<div>I'm using "smart bans" to expire large chunks of cache content. In good conditions everything works great but I want to serve stale content from the cache if the backend is down. It appears that Varnish evaluates the ban before the fetch operation fails, presumably meaning there's nothing left to serve to the client?</div>
<div><br></div><div>Any advice on handling this requirement, short of adding more backends? At this stage I'm not even sure that grace works with ban expressions. My VCL is very similar to this from the Varnish Book but it's not currently working:</div>
<div><br></div><div><a href="https://www.varnish-software.com/static/book/Saving_a_request.html#example-evil-backend-hack">https://www.varnish-software.com/static/book/Saving_a_request.html#example-evil-backend-hack</a></div>
<div><br></div><div>I read suggestions RE: only accepting ban requests when the backend is healthy but I don't see how that'll help, given that they are applied "just in time".</div><div><br></div><div>Steps to reproduce:</div>
<div><br></div><div>1. Warm cache using wget or whatever. Response is good and Varnish is caching as expected.</div><div>2. Kill the "normal" backend process.</div><div>3. Issue the ban expression (note that ban_lurker_sleep=0).</div>
<div>4. Hit URL with wget again and receive a 503 from Varnish (log output follows).</div><div><br></div><div>TIA for any help/advice,</div><div><br></div><div>Rob</div><div><br></div><div>3 SessionOpen  c 127.0.0.1 64767 <a href="http://0.0.0.0:8080">0.0.0.0:8080</a></div>
<div>3 ReqStart     c 127.0.0.1 64767 1914142754</div><div>3 RxRequest    c GET</div><div>3 RxURL        c /</div><div>3 RxProtocol   c HTTP/1.0</div><div>3 RxHeader     c User-Agent: Wget/1.12 (darwin10.6.0)</div><div>3 RxHeader     c Accept: */*</div>
<div>3 RxHeader     c Host: xxxx.dev</div><div>3 RxHeader     c Connection: Keep-Alive</div><div>3 VCL_call     c recv 6 41.3 7 42.5 9 48.5 12 59.3 14 64.3 16 70.3 18 75.3 20 82.3 26 97.3 lookup</div><div>3 VCL_call     c hash 1 24.3</div>
<div>3 Hash         c /</div><div>3 Hash         c xxxx.dev</div><div>3 VCL_return   c hash</div><div>3 ExpBan       c 1914142751 was banned</div><div>3 VCL_call     c miss 30 110.3 32 113.1 67 99.5 fetch</div><div>3 FetchError   c no backend connection</div>
<div>3 VCL_call     c error 47 163.3 48 164.5 restart</div><div>3 VCL_call     c recv 6 41.3 8 44.5 10 50.5 12 59.3 14 64.3 16 70.3 18 75.3 20 82.3 26 97.3 lookup</div><div>3 VCL_call     c hash 1 24.3</div><div>3 Hash         c /</div>
<div>3 Hash         c xxxx.dev</div><div>3 VCL_return   c hash</div><div>3 VCL_call     c miss 30 110.3 32 113.1 67 99.5 fetch</div><div>3 FetchError   c no backend connection</div><div>3 VCL_call     c error 47 163.3 49 167.3 deliver</div>
<div>3 VCL_call     c deliver 42 153.3 44 157.3 46 160.1 71 116.5 deliver</div><div>3 TxProtocol   c HTTP/1.1</div><div>3 TxStatus     c 503</div><div>3 TxResponse   c Service Unavailable</div><div>3 TxHeader     c Server: Varnish</div>
<div>3 TxHeader     c Content-Type: text/html; charset=utf-8</div><div>3 TxHeader     c Retry-After: 30</div><div>3 TxHeader     c Content-Length: 383</div><div>3 TxHeader     c Accept-Ranges: bytes</div><div>3 TxHeader     c Date: Thu, 12 Apr 2012 14:28:03 GMT</div>
<div>3 TxHeader     c X-Varnish: 1914142754</div><div>3 TxHeader     c Age: 0</div><div>3 TxHeader     c Via: 1.1 varnish</div><div>3 TxHeader     c Connection: close</div><div>3 Length       c 383</div><div>3 ReqEnd       c 1914142754 1334240883.726897955 1334240883.727870941 0.000333071 0.000754118 0.000218868</div>
<div>3 SessionClose c error</div><div>3 StatSess     c 127.0.0.1 64767 0 1 1 0 0 0 258 383</div><div><br></div>