We are using below code in Varnish 4.x:
if (req.http.X-Pool) {
ban("obj.http.X-Pool ~ " + req.http.X-Pool);
}
Now we are moving to Fastly which uses Varnish 2.x, so we are not getting what is the alternative to ban in Varnish 2.x
We are using below code in Varnish 4.x:
if (req.http.X-Pool) {
ban("obj.http.X-Pool ~ " + req.http.X-Pool);
}
Now we are moving to Fastly which uses Varnish 2.x, so we are not getting what is the alternative to ban in Varnish 2.x
For help with Fastly Varnish/VCL I recommend reading through both:
I would also generally recommend reaching out to [email protected] (they're a good group of people).
With regards to your question, I'm unfamiliar with
bans
in standard Varnish, but reading through https://varnish-cache.org/docs/trunk/users-guide/purging.html#bans it suggests that a ban is a way to prevent cached content from being served.So the solution depends on what you're trying to achieve when that happens.
If you just want to avoid the cache you can return a
pass
from the various subroutines likevcl_recv
andvcl_hit
(although from vcl_hit will cause a hit-for-pass and so that will cause the request to go straight to the backend.You could also add custom logic to either
vcl_recv
or maybe evenvcl_hit
(if you want to be sure the content requested was actually cached) and from there you could trigger anerror
which would send you tovcl_error
where you could construct a synthetic response:Alternatively from either
vcl_recv
orvcl_hit
you might want torestart
and then have a check for the restart and do something different (change the backend or the request in some way):