Cenote, the server which hosts Aquarionics and 64 other sites of varying complexity, has better things to do than spend its CPU and bandwidth on static content. It’s set up with a memory-limited version of Apache (which I can retune now I’ve bought a larger Linode, but was important at the time) so connections are at a bit of a premium.
The Enterprise solution to this is a CDN, of course, an international network of local stores that make everything better. But CDNs are traditionally tuned for heavy lifting – capital D Downloads rather than asset serving – and aren’t generally useful for one-man-band outfits where most of the readership is in RSS anyway. Plus, it’s something I’d like to do for work, so I was playing with tech.
The solution I’m currently using is Amazon’s Cloudfront, which works in a way pleasingly similar to Epistula (my old CMS)’s Fried Caching system. You point all your static files at a cloudfront-backed domain (in my case cdn.aquarionics.com) with exactly the same URL, and if it’s got it and it’s not too old, it sends it out. If it hasn’t got it, or it’s too old (defined by the caching headers on Aquarionics) it gets it from my server, sends it out, and saves it for later requestors.
This causes a minor problem if I want to change a static file quickly, because the CDN will cache it for ages, but I can either turn off the CDN, or I can invalidate part of the cache using boto like this:
cf = boto.connect_cloudfront(KEY,SECRET)
It’s currently costing me around $0.05/week, but it’s not very high traffic (Around 6k requests/month), but the site is a hell of a lot faster.