varnish cache cookie page

Hugo Cisneiros (Eitch) hugo.cisneiros at gmail.com
Thu Jun 21 18:13:43 CEST 2012


On Thu, Jun 21, 2012 at 12:38 PM, X.H.R.F.C. <xhrfc at yahoo.com> wrote:
> Is there any way to cache a page even the client - browser - is sending
> cookie in header?
> My entyre website has a 'logon' status + avatar in the top of the page. I
> use esi to load avatar, user name ... in that section.
> It seems like varnish dosen't cache my specifyed pages, even they are using
> esi feature .
> Rule:
>
> if (req.http.Authorization || req.http.Cookie) {
>         return (pass);
> }

Take out this rule to pass if there's a cookie on the request
(req.http.Cookie) and do a lookup instead of pass. Then it will cache
the page. But if your page changes because of a Cookie, every user
that hits the cache will have the information about the first user.

Since you use ESI, you could pass only the dynamic pages that changes,
and keep all other on cache. That's the best way to do it.

Another approach (not recommended because of the cache size and
potential to overload it) is to create one cache per type of cookie,
dealing in the vcl_hash section. For this, you can consult the mailing
list archives and documentation and there will be plenty of
information.

-- 
[]'s
Hugo
www.devin.com.br



More information about the varnish-misc mailing list