November 29, 2010
1 min read time

The cookie monster

When Varnish Cache was designed, back in 2006, there where not that many caching proxies to talk of. There was, of course, Squid, but Squid had most of it's focus on being a forward proxy, not a reverse proxy, so we felt we shouldn't copy to much from squid.

The main difference between the forward and the reverse proxy is that the reverse proxy is under complete control of the administrators of the web site it accelerates. We believe this difference is significant and because there is no standard regulating how the reverse proxies should act we had to define it ourselves.

A lot of people running Varnish are not aware of one simple fact. If the client sends you a cookie Varnish will not issue a cached page but instead fetch a new page from the backend servers. Varnish takes a cookie as a good indication that the content is specially adapted and will, with the default configuration, not cache it. So, having a cookie that is not handled correctly will completely kill your performance.

The best way to spot a cookie would be to use browser extensions such as Live HTTP Headers for Firefox or similar tools. If you suspect this might apply to you please have a look at the following pieces of documentation:

  • Achieving a high hitrate
  • Handling cookies in Varnish