Making varnish cache only certain requests with multiple backends

Debraj Manna subharaj.manna at gmail.com
Thu May 19 14:55:50 CEST 2016


Can you please explain a bit more what advantage I will have by using
return(pass). Are you saying if I use return(pipe) then the client's
subsequent request will start getting 404 Error?

 My intention is if the header req.http.Type == "p" then i want to treat as
if varnish is not present for those requests and the request going straight
to backend.

On Thu, May 19, 2016 at 4:41 PM, Dridi Boukelmoune <dridi at varni.sh> wrote:

> On Thu, May 19, 2016 at 10:16 AM, Debraj Manna <subharaj.manna at gmail.com>
> wrote:
> > 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";
> > }
>
> You don't need to duplicate backend definitions, your directors d and
> r can share two backends b1 and b2.
> > 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);
> >    }
>
> It looks OK but if your client sends subsequent HTTP requests, Varnish
> won't see them after a return(pipe). You may use return(pass) instead,
> to bypass Varnish for individual requests.
>
> Dridi
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20160519/0bc7da0a/attachment.html>


More information about the varnish-misc mailing list