Using Amazon S3 as CDN, Part 2 - Cacheability

In my last post I compared using Amazon S3 as a CDN to other low cost alternatives. What was clear was that S3 performed badly when compared to the true CDNs. Not such a surprising outcome; S3 was not designed to be a CDN.

The real surprise to me was that CacheFly, the lowest cost CDN I tested, performed better than the much higher priced options.

My performance were pure HTTP GET based and utilized the monitoring service Pingdom. What performance monitoring services don't monitor is how quickly a website load feels to the end-user.

A lot can be done to make a website "feel" faster most of these techniques are outlined in the book High Performance Web Sites by Steve Souders of Yahoo!. Most of the book's content can be read for free on the Yahoo! Developer Network.

The simplest way to increase performance is to minimize requests to your server by setting proper Expires and Cache-Control headers so that your static content can be cached.

When I tested the CDN options for cacheability only Panther Express and my DIY Nginx web server EC2 servers returned proper "cacheable" headers.

S3 and CacheFly returned no "cache-friendly" headers and EdgeCast returned proper headers but the server time was inaccurate which could lead to caching issues.

Amazon S3

CDN Cacheability - Amazon S3

Panther Express

CDN Cacheability - Panther Express

EdgeCast

CDN Cacheability - EdgeCast

CacheFly

CDN Cacheability - CacheFly

I found no way to add expires headers to files hosted on CacheFly. You can add custom headers to files in S3.

By setting your Expires headers on your static files far into the future you can create a cheap CDN with S3 that can "feel" as fast a traditional CDN. You'll need to automate this and make it part of your deployment process which ideally renames the deployed files to contain revision numbers so that you can really set those Expires headers far in the future.

Like this post? Subscribe by email or say hello on Twitter: @dcancel.