Skip to content

Instantly share code, notes, and snippets.

Last active Aug 11, 2020
What would you like to do?
Recursive PURGE from BASE URL for Fastly


  • wget
  • curl


$ bash

$ curl -sL | bash -s
[ "${base_url}" = "" ] && echo "\$1(base URL) is required" && exit 1
purge_url() {
local url="${1}"
curl -s -X PURGE ${url}
echo "purged ${url}"
sleep 0.1
for url in $(LANG=C wget -p -nv -nd -r --spider ${base_url} -o /dev/stdout | grep URL | sed -e 's/URL://' | awk '{print $3}'); do
purge_url "${url}"
[[ "${url}" =~ /$ ]] && purge_url "${url}index.html"
Copy link

bigtiger commented Aug 11, 2020


We nearly used this for a project I was working on. In our case we were able to use Surrogate Keys to tag all the content we needed purged and then make a single call to the API to instruct Fastly to purge all content tagged with that key.

Leaving this note for future travelers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment