Created
March 21, 2017 15:47
-
-
Save razvanphp/59dd5f0a94af3fd7b432eba61b382699 to your computer and use it in GitHub Desktop.
ignore UTM parameters from varnish hashing function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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