Skip to content

Instantly share code, notes, and snippets.

@razvanphp
Created March 21, 2017 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save razvanphp/59dd5f0a94af3fd7b432eba61b382699 to your computer and use it in GitHub Desktop.
Save razvanphp/59dd5f0a94af3fd7b432eba61b382699 to your computer and use it in GitHub Desktop.
ignore UTM parameters from varnish hashing function
sub vcl_hash {
# Strip out Google Analytics campaign variables
# They are only needed by the javascript running on the page
# utm_source, utm_medium, utm_campaign, gclid, …
hash_data(regsub(regsuball(req.url, "(vid|ef_id|gclid|kw|cof|siteurl|zanpid|origin|emst|sc_[a-z]+|utm_[a-z]+|mr:[A-z]+)=[%@\.\-\:\+_A-z0–9]+&?", ""), "(\?&|\?|&)$", ""));
if (req.http.X-Forwarded-Proto ~ "^(https|http)$") {
hash_data(req.http.X-Forwarded-Proto);
}
if (req.http.host) {
hash_data(req.http.host);
} else {
hash_data(server.ip);
}
return (lookup);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment