Caching cookies with Varnish 4

Thomas Lecomte thomas.lecomte at virtual-expo.com
Wed May 13 23:30:27 CEST 2015


On Wed, May 13, 2015 at 5:33 PM, Raymond Gonzalez <raygo22 at gmail.com> wrote:
> I want to be able to cache pages that have a cookie. Let's say I have a
> cookie called "testcookie" that I set up with php.
>
> [...]
>
> Any idea? Thanks!

Hello Raymond,

Since your VCL code doesn't return anything itself, the default VCL
implementation is run after your own.
The default vcl_recv subroutine will return (pass) if req.http.Cookie
is present, which is the first reason why your page isn't going to be
cached (in fact, it won't even be looked up).
Also, in vcl_backend_response, the returned object won't be cached if
it contains a Set-Cookie HTTP header.

You might want to take care of these cases yourself if you want to
cache those kind of pages, instead of leaving it to the default VCL
implementation.

Regards,

-- 
Thomas Lecomte



More information about the varnish-misc mailing list