Skip to content

Instantly share code, notes, and snippets.

@andycochrane
Last active March 18, 2018 15:18
Show Gist options
  • Save andycochrane/ebc098d028cff7d0d4986685f27d7af9 to your computer and use it in GitHub Desktop.
Save andycochrane/ebc098d028cff7d0d4986685f27d7af9 to your computer and use it in GitHub Desktop.
Generate a space-delimited list of paths for Facebook's batch invalidator
# If you have a static site with just html files and have a setup which allows
# you to access pages with pretty URLs (e.g. /about/) without the index.html
# extension, this will generate the list of paths, which you can paste straight
# into the Facebook batch invalidator.
# If you are not a Mac user, you can change pbcopy to your choice of tool to
# copy to clipboard, or remove it and just copy manually from the command line.
# Just change the values of the FOLDER and DOMAIN vars to your own.
FOLDER="public"
DOMAIN="https://www.yourdomain.com"
DOMAIN=$(echo "$DOMAIN" | sed -e 's/[\/&]/\\&/g') # Escape the domain
find "$FOLDER"/ -type f -name *.html | sed "s/$FOLDER\//$DOMAIN/g" | sed "s/index.html//g" | xargs | pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment