Making varnish cache only certain requests with multiple backends
Debraj Manna
subharaj.manna at gmail.com
Thu May 19 10:16:14 CEST 2016
Hi,
We are using varnish for multiple round robin backends. as shown below:-
backend d1 {
.host = "172.16.84.69";
.port = "9802";
}
backend d2 {
.host = "172.16.84.68";
.port = "9802";
}
backend r1 {
.host = "172.16.84.69";
.port = "9802";
}
backend r2 {
.host = "172.16.84.68";
.port = "9802";
}
Our requirement is if the urls is of form /d/r we will send the request to
one of the backends given by r.backend() else we will send the request to
d.backend(). If the url is of form /d/r but contains a header of Type = p
then we will bypass varnish and send the request directly to backend. The
vcl looks something like below:-
sub vcl_recv {
# ...
# Don't cache r requests with type = p
if(req.http.Type == "p") {
req.backend_hint = r.backend();
return (pipe);
}
if(req.url ~ "^/d/r/") {
set req.backend_hint = r.backend();
} else {
set req.backend_hint = d.backend();
}
Can some one please let me know if the below code is the best way to
achieve what I am trying to do?
if(req.http.Type == "p") {
req.backend_hint = r.backend();
return (pipe);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20160519/54b63958/attachment.html>
More information about the varnish-misc
mailing list