return(lookup) in vcl_recv() to cache requests with cookies?

Nathan Kinkade nkinkade at creativecommons.org
Thu Mar 3 01:40:34 CET 2011


This seems like one of those perennial questions where the required
reply is RTFM or "review the list archives because it's been asked
thousands of times", but for whatever reason, I can't find an answer
to this aspect of caching requests with cookies.  In the examples
section of the 2.1 VCL reference (we're running 2.1.5) there is an
example for how to force Varnish to cache requests that have cookies:

http://www.varnish-cache.org/docs/2.1/reference/vcl.html#examples

The instruction is to to return(lookup) in vcl_recv.  However, I have
found that that doesn't work for me.  The only way I can seem to get
Varnish 2.1.5 to cache a request with a cookie is to remove the
Cookie: header in vcl_recv.  Other docs I found also seem to indicate
that return(lookup) should work.  For example:

http://www.varnish-cache.org/trac/wiki/VCLExampleCacheCookies#Cachingbasedonfileextensions

There are also loads of other examples on the 'net that indicate that
return(lookup) in vcl_recv should work.  I though maybe it was cache
control headers returned by the backend causing it not to cache, but I
tried stripping all those out and it still didn't cache.  Am I just
missing something here, or is the documentation not fully complete?  I
don't necessarily want to strip cookies.  I just want to cache, or
not, based on some regular expression matching the Cookie: header sent
by the client.

Thanks,

Nathan




More information about the varnish-misc mailing list