Skip to content

Instantly share code, notes, and snippets.

@rezan
Last active Sep 11, 2019
Embed
What would you like to do?
Purge multiple urls from a request body
# Purge multiple urls from a request body
import edgestash;
import synthbackend;
import xbody;
sub vcl_recv {
unset req.http.purgelist;
if (req_top.method == "PURGELIST") {
if (req.esi_level == 0) {
set req.http.purgelist = "yes";
return(pass);
} else {
return(purge);
}
}
}
sub vcl_backend_fetch {
if (bereq.http.purgelist) {
set bereq.backend = synthbackend.mirror();
}
}
sub vcl_backend_response {
if (bereq.http.purgelist) {
xbody.regsub("(.*)\n?", "{{ > \1 }}");
edgestash.parse_response();
}
}
sub vcl_deliver {
if (req.method == "PURGELIST") {
edgestash.execute();
return (deliver);
}
if (req_top.method == "PURGELIST") {
return (synth(200));
}
}
sub vcl_synth {
if (req_top.method == "PURGELIST") {
synthetic("PURGED: " + req.url + {"
"});
return (deliver);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment