Skip to content

Instantly share code, notes, and snippets.

@mmay
Created May 29, 2014 01:05
Show Gist options
  • Save mmay/8c7294c4204bbb192e3c to your computer and use it in GitHub Desktop.
Save mmay/8c7294c4204bbb192e3c to your computer and use it in GitHub Desktop.
Fastly Purge
fastly = Fastly.new(api_key: FASTLY_API_KEY)
# Site wide purge
s = fastly.get_service service_id
s.purge_all
# URL Purge
# "www.cool.com/blah.json"
fastly.purge("/blah.json")
# Surrogate-Key Purge
# In controller GET actions
response.headers['Surrogate-Control'] = "max-age=3600"
response.headers['Surrogate-Key'] = "mykey"
# In controller PUT, POST, DELETE actions
fastly.purge("mykey")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment