Skip to content

Instantly share code, notes, and snippets.

@dlitvakb
Created March 7, 2013 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlitvakb/de7fb1bf78c848f6eafa to your computer and use it in GitHub Desktop.
Save dlitvakb/de7fb1bf78c848f6eafa to your computer and use it in GitHub Desktop.

Purge All The Things

Purging files is such a frequently used API call, We gave you shortcuts for it!

Why?

Everyday our API receives thousands of purge calls, being one of the most used, so we tried to help the automation of those calls as much as possible.

Our job in NetDNA is to make your CDN Management as happy and fast as possible. Step by step, we're improving our developer tools for doing so.

Ruby and Python Clients

Today we released a new version of both clients including this shortcut.

zone_id = 12345

# Purge a Single File
api.purge(zone_id, '/some/file')

# Purge Multiple Files (Sequential)
api.purge(zone_id, ['/some/file', '/another/file', ..., '/more/files'])

# Purge Zone Cache
api.purge(zone_id)

Responses

For individual file purges or zone purges you will receive a normal JSON response or raise an exception on purge error.

For multiple file purges, you will receive a JSON with the filenames as keys and the JSON response for each file purge. On errors, you will receive the JSON with code and message.

If you prefer to receive your errors as JSON instead of exceptions you can add to your calls (also works with every other API call):

Python

api.purge(12345, '/file', debug_json=True)

Ruby

api.purge(12345, '/file', :debug_json => true)

All of these calls behaves the same as api.delete('/zones/pull.json/12345/cache'), just making it a lot easier for you!!!

Facepalm Time

Do you have an idea how much time I spent this morning debugging this change in our Ruby Library??? 1 Hour.

Reason I mistaken a . for a , inside a string and my editor's font was so small that I couldn't tell the difference. I was pointing to the wrong URL the whole time.

After some laughs and facepalms. We pushed this changes to our new versions!

Contribute

Want to help us improve? Send us your feedback!

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