Skip to content

Instantly share code, notes, and snippets.

@razvanphp
Last active March 21, 2017 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save razvanphp/8ddaeca0968163442ba03a8d0369a53b to your computer and use it in GitHub Desktop.
Save razvanphp/8ddaeca0968163442ba03a8d0369a53b to your computer and use it in GitHub Desktop.
normalize request params & strip cookies in varnish
sub vcl_recv {
# Happens before we check if we have this in cache already.
#
# Typically you clean up the request here, removing cookies you
# don't need, rewriting the request, etc.
if ((req.url ~ "^/$" ||
req.url ~ "^/(frauen|maenner|kinder|outlet|marke)(/.+)?" ||
req.url ~ "^/api/(seen2bought/|similarProduct/|product\?)" ||
req.url ~ "\.(css|js)\?.*" ||
req.url ~ "\.(png|gif|jpg|ico|js|css|xml|pdf|woff|ttf)$" ||
) && req.method == "GET") {
# Normalize the query parameters
set req.url = std.querysort(req.url);
# Strip the cookies
unset req.http.cookie;
return(hash);
} else {
return(pass);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment