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.
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)
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):
api.purge(12345, '/file', debug_json=True)
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!!!
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!
Want to help us improve? Send us your feedback!