varnish changes HEAD to GET on backend request

Taylan Develioglu tdevelioglu at ebuddy.com
Wed Apr 14 18:22:37 CEST 2010


Hello Poul-Henning,

On Wed, 2010-04-14 at 17:52 +0200, Poul-Henning Kamp wrote:
> In message <1271259971.28720.86.camel at 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.





More information about the varnish-misc mailing list