Search code examples
cdnrackspace-cloudrackspacecloudfiles

When a file is updated on cloud-files, how long does it take to update the edge CDNs?


Consider a file which is published to Rackspace Cloud Files. If I update this file at noon, how long does it take to migrate to the edge CDNs? Does the CDN only expire the file based on the container's TTL, or does Cloud Files notify the CDN the moment a file has changed?

During development, a user can edit/update a set of images/files and the updated files are pushed to Cloud Files (with the same file name). I'd like to at that point ensure that the file is pushed out to the edge CDNs. I've read up on purging and I don't think that's the proper use case. I've also read up on TTL and I don't think it's appropriate to set the container to a low TTL as these images won't change very often. But when they do change, I expect the change to cascade quickly to the edge CDNs.

Options

  1. Configure Cloud Files to immediately push changes to the edge CDNs. (Is this even possible?)
  2. When a file changes, delete the old file and use a new name for the updated file. (This seems to be the best option, but I also like having predictable file names -- this would require pseudo-random or time-stamped file names.)

Solution

  • The way a CDN works is that when the first request for a file is made, the resource gets retrieved from the origin server. The resource gets cached on the CDN's edge server during response before it gets delivered to the client. Therefore, upon subsequent requests the resource will be delivered via the CDN.

    This means that if you have an image being delivered from an edge server and then make a change to that image on your origin server, the old image will continue to be delivered via the CDN until you do one of the following:

    • purge the cache, thus allowing the new version of the image to be retrieved from the origin by the edge server
    • wait until the max-expire time runs out so that the edge server will look to the origin for any changes
    • if you're using a push zone, use file name versioning as you suggested.

    Some CDN providers offer the option to use a push or pull zone (see the difference here). Therefore it depends on which method you are using. If you implement a push zone where you manually upload all of your files to be hosted on the CDN's storage cloud then file name versioning is your best option. If you are using a pull zone which automatically detects your static assets and rewrites the url to reflect the CDN URL, then purging the asset after it is edited is likely your best option.