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!

  • Lisa Ford

    Really nice write up, I was looking for this Rackspace site is overcomplicated for its own good, It’s worth mentioning that people may struggle with the command if they are using Rackspace UK file cloud api, since you need to change the auth.api.rackspacecloud to lon.auth.api.rackspacecloud furthermore if anyone is looking to set the TTL’s I found http://www.bybe.net/blog/how-to-fix-rackspace-file-cloud-leverage-browser-caching-via-api-ssh.html last night and might be useful to some, since AGAIN Rackspace over complicate things by not enabling options they should have in the Control Panel.


    • Nick

      Just in case anyone comes across this post like I did. You can now purge files from the Control Panel (cog icon next to each file).

  • Pingback: 朱使林言()

  • Pingback: 袁仙之妾()

  • Pingback: 卢木玖夫()

  • Pingback: cascading failure()

  • William Huster

    Exactly what I was looking for when I checked Rackspace’s docs. Thanks!