Mailing List Archive

varnish changes HEAD to GET on backend request
First, hi to all.

I have the following problem I was hoping someone could shed some light
on:

The default behavior of varnish 2.1 seems to be changing HEAD requests
into GET before sending them to the backend.

I tried changing bereq.request to "HEAD" if req.request is "HEAD" in
vcl_pass and vcl_miss:


sub vcl_pass {
if (req.request == "HEAD") {
set bereq.request = "HEAD";
}
}

sub vcl_miss {
if (req.request == "HEAD") {
set bereq.request = "HEAD";
}
}

And it didn't help, what am I doing wrong here?


_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
http://lists.varnish-cache.org/mailman/listinfo/varnish-misc
Re: varnish changes HEAD to GET on backend request [ In reply to ]
In message <1271259971.28720.86.camel@oasis>, Taylan Develioglu writes:

>The default behavior of varnish 2.1 seems to be changing HEAD requests
>into GET before sending them to the backend.

Yes, in the vcl_miss{} path, varnish currently only uses GET to the
backend, the presumption is that if we get a HEAD request, we're
also likely to need the object body soon after.

> sub vcl_pass {
> if (req.request == "HEAD") {
> set bereq.request = "HEAD";
> }
> }

A HEAD being pass'ed will go unmodified to the backend, so this
should do nothing


> sub vcl_miss {
> if (req.request == "HEAD") {
> set bereq.request = "HEAD";
> }
> }

This will confused varnish program logic, and do nothing good.

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.

_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
http://lists.varnish-cache.org/mailman/listinfo/varnish-misc
Re: varnish changes HEAD to GET on backend request [ In reply to ]
Hello Poul-Henning,

On Wed, 2010-04-14 at 17:52 +0200, Poul-Henning Kamp wrote:
> In message <1271259971.28720.86.camel@oasis>, Taylan Develioglu writes:
>
> >The default behavior of varnish 2.1 seems to be changing HEAD requests
> >into GET before sending them to the backend.
>
> Yes, in the vcl_miss{} path, varnish currently only uses GET to the
> backend, the presumption is that if we get a HEAD request, we're
> also likely to need the object body soon after.

Sadly this presumption is wrong for our application. The HEAD call is
performed to make a client aware of the existence of the object and
validate its location.

The client only fetches the object when needed. If it is not needed, it
never gets fetched.

Always performing a GET puts unnecessary load on the backend in our
situation and creates objects cached by varnish that never are
requested.


> > sub vcl_pass {
> > if (req.request == "HEAD") {
> > set bereq.request = "HEAD";
> > }
> > }
>
> A HEAD being pass'ed will go unmodified to the backend, so this
> should do nothing

Thank you for clearing that up.

Letting HEAD requests pass unmodified is a workable solution, but it
would be nice if varnish could cache the HEAD's too.

>
> > sub vcl_miss {
> > if (req.request == "HEAD") {
> > set bereq.request = "HEAD";
> > }
> > }
>
> This will confused varnish program logic, and do nothing good.
>

Really? I'm not familiar with the inner workings of Varnish.

I admit it's strange to do a set bereq.request = req.request, but that's
only because the default behavior was unexpected (to me at least) and
I'm trying to work around it.

I would expect a HEAD would stay a HEAD unless specified otherwise.


_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
http://lists.varnish-cache.org/mailman/listinfo/varnish-misc
Re: varnish changes HEAD to GET on backend request [ In reply to ]
In message <1271262157.28720.110.camel@oasis>, Taylan Develioglu writes:

>Always performing a GET puts unnecessary load on the backend in our
>situation and creates objects cached by varnish that never are
>requested.

In that case, just always pass the HEAD requests.

Poul-Henning

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.

_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
http://lists.varnish-cache.org/mailman/listinfo/varnish-misc
Re: varnish changes HEAD to GET on backend request [ In reply to ]
I feel incredibly dense, but I can't get it to do what I want.

redefined vcl_recv:

sub vcl_recv {
if (req.request == "HEAD") {
return(pass);
}
}

HEAD is still changed into GET.

On Wed, 2010-04-14 at 18:36 +0200, Poul-Henning Kamp wrote:
> Poul-Henning Kamp


_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
http://lists.varnish-cache.org/mailman/listinfo/varnish-misc
Re: varnish changes HEAD to GET on backend request [ In reply to ]
In message <1271264159.28720.118.camel@oasis>, Taylan Develioglu writes:


>sub vcl_recv {
> if (req.request == "HEAD") {
> return(pass);
> }
>}
>
>HEAD is still changed into GET.

That's a bug, please open a ticket.


--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.

_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
http://lists.varnish-cache.org/mailman/listinfo/varnish-misc