Last active
August 29, 2015 14:14
-
-
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
This file contains 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
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