https://github.com/rareloop/wp-varnish-invalidator
https://github.com/rareloop/wp-varnish-invalidator
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rareloop/wp-varnish-invalidator
- Owner: Rareloop
- Created: 2016-01-21T13:43:42.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-21T13:56:11.000Z (about 10 years ago)
- Last Synced: 2024-12-29T07:43:14.644Z (about 1 year ago)
- Language: PHP
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# VCL setup
````
# Allow cache invalidation
if (req.method == "BAN") {
# Same ACL check as above:
if (!client.ip ~ purge) {
return(synth(403, "Not allowed."));
}
# Compare against the hostname ignoring the port.
# When using Vagrant we're port forwarding which throws all the
# matching off
if(req.http.X-Ban-Method == "regex") {
ban("req.http.Host ~ ^" + regsuball(regsub(req.http.Host, ":[0-9]+", ""), "(\.|\-)", "\\\1") +
" && req.url ~ " + req.http.X-Ban-Regex);
} elseif (req.http.X-Ban-Method == "url") {
ban("req.http.Host ~ ^" + regsuball(regsub(req.http.Host, ":[0-9]+", ""), "(\.|\-)", "\\\1") +
" && req.url == " + req.http.X-Ban-Url);
} else {
return(synth(400, "Valid X-Ban-Url not provided"));
}
# Throw a synthetic page so the
# request won't go to the backend.
return(synth(200, "Ban added"));
}
````