Edge Purge Content from Rackspace Cloud Files via curl

When the Rackspace Cloud Files product received Edge Purge functionality via the API, I didn’t give it much thought as I didn’t use the CDN functionality for any of my personal projects. That changed recently and I started doing some work with the CDN (powered by Akamai). All was fine until I realized I had set the TTL for the objects too high for my testing and wasn’t receiving the right content. Below you’ll find the appropriate methods for doing an edge purge of an object and container via curl using the API.

First, you’ll need to authenticate using your API key and username.

  1. $ curl -D – -H "X-Auth-Key: yourAPIkey" -H "X-Auth-User: yourUsername" https://auth.api.rackspacecloud.com/v1.0

You should receive the following:

  1. HTTP/1.1 204 No Content
  2. Server: Apache/2.2.13 (Red Hat)
  3. X-Storage-Url: https://storage.clouddrive.com/v1/yourAccountHash
  4. Content-Type: application/octet-stream
  5. Date: Date & Time
  6. X-Auth-Token: yourAuthToken
  7. X-Storage-Token: yourStorageToken
  8. X-Server-Management-Url: https://servers.api.rackspacecloud.com/v1.0/yourAccountNumber
  9. Connection: Keep-Alive
  10. X-CDN-Management-Url: https://cdn1.clouddrive.com/v1/yourAccountHash
  11. Content-Length: 0

You now have the information you need to do the Edge Purge from the Akamai fronted CDN. To delete an object, you’ll need the “X-Auth-Token” and “X-CDN-Management-Url”.

To do an Edge Purge of the given object “foo.txt” in the container “bar”, send the following via curl:

  1. $ curl -D – -X DELETE -H "X-Auth-Token: yourAuthToken" -H "X-Purge-Email: your@email.address"  https://cdn1.clouddrive.com/v1/yourAccountHash/bar/foo.txt

You’ll receive the following in response as well as an email to your@email.address.

  1. HTTP/1.1 204 No Content
  2. Date: Date & Time
  3. Server: Apache
  4. X-Akam-Est-Time: 420
  5. X-Akam-Result-Code: 100
  6. Content-Length: 0
  7. Connection: close
  8. Content-Type: text/plain; charset=UTF-8

To do an Edge Purge of the container “bar”, send the following via curl:

  1. curl -D – -H "X-Auth-Token: yourAuthToken" -H "X-Purge-Email: your@email.address" -X DELETE https://cdn1.clouddrive.com/v1/yourAccountHash/bar/

You should receive a response identical to the one you did for object Edge Purge.

That’s it!

Thumbs DownThumbs Up (+1 rating, 1 votes)
Loading ... Loading ...