emptees on cloudfront
10 Jan 02009

Just before the new year, we put Emptees on CloudFront. The increased responsive was noticeable (even without looking at the network timeline). And, because we were already using S3, setting up a CloudFront distribution was easy. Highly recommended.
In deploying on CloudFront, we also started taking better advantage of the browser cache by setting far-future expiration dates in the Cache-Control headers of all our S3 assets (and of all the static assets served from our own servers as well). It’s easy (when you have stats from RPM to obsess over) to bog yourself down in tweaking your back-end application in ways that will never be noticed by your users. But there are many simple things that can be done to significantly increase the performance of an application without ever touching the back-end code.
An issue I’ve been struggling with in using S3 + CloudFront is what to do with our application’s stylesheets and Javascripts. First, in order to set far-future expirations, the assets need to be versioned somehow (so that changes to an asset are picked up by the browser). I haven’t been able to come up with an effective strategy for versioning static assets yet. I would love to do it as a part of our deployment process in Capistrano, but most of my attempts so far have been really ugly. Second, S3 doesn’t automatically compress CSS or Javascript before serving. It isn’t a problem to upload a compressed version of a file to S3, but not all browsers are capable of handling compressed assets. Granted, the requisite user agent sniffing is trivial to implement.
If I come up with a nice solution, I’ll post it here.