Last active
September 11, 2019 18:21
-
-
Save rezan/c4a37109c878a0ce48e49c1154bc4d4d to your computer and use it in GitHub Desktop.
Purge multiple urls from a request body
This file contains hidden or 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
# 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