CODE:
acl purge {
"localhost";
"10.0.0.1";
}
sub vcl_recv {
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
lookup;
}
}
sub vcl_hit {
if (req.request == "PURGE") {
set obj.ttl = 0s;
error 200 "Purged.";
}
}
sub vcl_miss {
if (req.request == "PURGE") {
error 404 "Not in cache.";
}
}With this in your VCL file, we have implemented purging through HTTP. That means that if you now send aCODE:
PURGE / HTTP/1.0to Varnish over port 80 (restricted to client with IP 10.0.0.1), your / document will be purged. However, this way of implementing purge does not support wildcard purge yet (because of restrictions in VCL).