Skip to content

Instantly share code, notes, and snippets.

@pprishchepa
Last active January 18, 2017 03:51
Show Gist options
  • Save pprishchepa/caa3985719977c62fec203dc203b72c1 to your computer and use it in GitHub Desktop.
Save pprishchepa/caa3985719977c62fec203dc203b72c1 to your computer and use it in GitHub Desktop.
varnish-caching-suggestion.txt
vcl 4.0;
...
sub vcl_recv {
...
# Protecting against the HTTPOXY CGI vulnerability.
unset req.http.proxy;
# Remove the Google Analytics added parameters.
if (req.url ~ "(\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=") {
set req.url = regsuball(req.url, "&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\-\.%25]+)", "");
set req.url = regsuball(req.url, "\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\-\.%25]+)", "?");
set req.url = regsub(req.url, "\?&", "?");
set req.url = regsub(req.url, "\?$", "");
}
# Strip hash, server doesn't need it.
if (req.url ~ "\#") {
set req.url = regsub(req.url, "\#.*$", "");
}
# Strip a trailing ? if it exists
if (req.url ~ "\?$") {
set req.url = regsub(req.url, "\?$", "");
}
# Normalize the query arguments
set req.url = std.querysort(req.url);
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment