Skip to content

Instantly share code, notes, and snippets.

@vparihar01
Last active August 29, 2015 14:14
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 vparihar01/db70ca2122dbf850766c to your computer and use it in GitHub Desktop.
Save vparihar01/db70ca2122dbf850766c to your computer and use it in GitHub Desktop.
varnish cache hack to purge all request url which are originated due to url's
if (req.method == "PURGE") {
if (!client.ip ~ purge) {
return(synth(405,"Not allowed."));
}
# Throw a synthetic page so the
# request won't go to the backend.
if (req.url ~ "(\/.*\?$)"){
ban("req.http.host == " + req.http.host + " && req.url ~ " + req.url + "\?(.*)?$");
}
if (req.url ~ "(\/search\/smartphone\/.*?$)"){
set req.url = regsuball(req.url, "[\?]+$", "");
ban("req.http.host == " + req.http.host + " && req.url ~ " + req.url + ".*?$");
}
return(synth(200,"Purged"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment