Question

So I'm trying to get Varnish "HITS" in a simple testing page made with Silex. The Response has the necessary headers for being cached, but it is not being cached. It seems to be because Google Analytics is installed.

Is there a way to tell Varnish (in cloudControl) to ignore the Google Analytics cookies?

View test site here: http://www.delphinedhaenens.be (MISS)


Update: without the Analytics code the cache HITS, so I'm thinking that maybe cloudControl is not ignoring the new Universal Analytics cookies ("_ga.")... can somebody from cloudControl confirm this?

View same site with NO GA code: http://ga-delphius.cloudcontrolled.com (HIT)

And the same, with Classic GA code: http://gaclassic-delphius.cloudcontrolled.com (HIT)

Was it helpful?

Solution

Cloudcontrol routing tier (*.cloudcontrolled.com) is handling also GA universal cookies from today. Please have a look at simple examples:

http://classic-gacachingtest.cloudcontrolled.com/

http://universal-gacachingtest.cloudcontrolled.com/

What is interesting official varnish documentation suggests using the rule which will handle all types of GA cookies but will also strip other types of cookies as well if only they start with "_" which is not so cool.

OTHER TIPS

You can remove __utm cookies set by GA from client request in vcl_recv like this:

sub vcl_recv {
    if (req.http.Cookie) {
        set req.http.Cookie = regsuball(req.http.Cookie, "(^|; ) *__utm.=[^;]+;? *", "\1");
    }
    if (req.http.Cookie ~ "^[\s;]*$") {
        unset req.http.Cookie;
    }

This will remove all __utma, __utmb, __utmc cookies and so on.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top