Amazon Cloudfront 1hr TTL

I just recently read that you can now set the TTL of an object on Amazon’s Cloudfront to 1 hr instead of the 24 hr minimum that it used to be.  I only found this out because I was reading through the discussion forums looking to see if there was an ETA of when this could be done.  Didn’t know this had been around since April.  Since Amazon didn’t include it on any of the monthly announcements of new/improved features I figured I would share.

The default for an object is still 24 hours, but you can use the HTTP Header Expires to set a different expiration.  If the time is less than an hour, Cloudfront will default to 1 hour.  I still wish there was a way to expire a given object at anytime, but this is a big step forward.  However, it would be nice if there was a tool out there that would allow me to set a default expires time period when I upload an object to S3 based on the content type.  In my case, I can usually have my images set to a 24 hour TTL, but there are some HTML, CSS and Javascript files that I would want at only an hour.  Right now I use S3Fox and Cloudberry to manage my S3 buckets.

Amazon Cloudfront

In the last couple of weeks I have been working with Amazon’s Cloudfront to deliver small javascript files.  It has turned out to be a pretty good experience.  The only problem we have had so far is that you can not invalidate the cache on the CDN servers and force them to immediately fetch new copies from Amazon S3.  You have to wait 24 hours for the content to expire.  If you plan on your files changing often you will need to find a way to version your files.  In my case the version doesn’t work too well as we can’t easily change the file references to these javascript files.