views:

263

answers:

2

Hi,

I don't quite understand how Google Analytics cookies work with Varnish.

  • Do pages that contain GA cookie not get cached?
  • Do I need to remove the GA cooke in vcl_recv?
  • If I do remove them, does that stop GA tracking visitors?
+1  A: 

According to varnish IRC channel, because the cookie is on the client side, varnish won't touch it. But I don't understand why the Wiki would show an example of stripping it out?

Tom
+1  A: 

Cookies invalidate the cache if the Vary header is not set. For example, a client that goes to a URL with a certain login cookie will receive a different page than a client with a different cookie.

In order to cache a page that has cookies that do not affect the cache-ability of the page (for example, Google Analytics on static sites), the cookies must be stripped or the cache won't know whether two pages should be considered the same resource.

CapnKernul
Does the GA cookie actually talk to Varnish at all? because it's client side and connects to Google's Servers? Secondly: If I do strip the GA cookie, does analytics still get recorded?
Tom
Varnish doesn't do anything with the Cookie. All it does is pass it along to the backend service. The cookie is mainly there to keep client side state about browsing habits. It's safe to strip it from requests. Analytics will still be recorded.
CapnKernul