Surf the Dream A discourse of links and articles from Justin Avery

Setting Cache with Amazon S3

As part of my other post about Alexander Headland surf I had to get the images from the camera to the laptop to the server to you.

Most of those steps are pretty straight forward, but the path from the laptop to the server can be done better than you might think.

I use Amazon S3 for some storage hosting, I put some backups up there, I used to synchronise all of my images up to S3 and I even serve all of the assets from my wordpress surferm.ag site from Amazon S3.

The uploading part is really simple with S3 which is one of the reasons it’s really popular, also it’s a lot cheaper to pay for diskspace and data transfer with them over someone like Media Temple.

For a long time though I was blindly uploading my images/css/js without thinking about cache. Just because the assets were being served from a content distribution network (CDN) didn’t mean that you yourself couldn’t benefit form a little cache.

When you’re uploading your files to Amazon S3 be sure to set Metadata against the files AS YOU UPLOAD. Once they’re up there they can not be changed, so do this during the upload.

Set the met data Cache-Control to the value of max-age=864000. This gives you 10 days worth of cache on the images you upload (increase it if you need).

Easy huh.

Surf the Dream is a blog that has been running since the mid 2000's when it started on BlogSpot. Over the years it's been rebranded as justinavery.me (now my resume) and JaveryDesign.com (which now redirects back to this site).

I offer consultation services through Simple Things, produce a range of educational pocket notebooks, write about the Universe and run a responsive design and a RWD Weekly Newsletter