Nice post, thanks for sharing.<p>I recently had a similar problem - I needed to serve dynamically resized images via CloudFront (with the images being stored in S3). Images are resized on-demand - if they exist they are served directly from S3. If not, they are resized and stored in S3, then the next request will serve them directly from S3.<p>It works rather well, although it is quite susceptible to the thundering herd problem - putting it behind a reverse proxy that supports collapsed forwards would probably help here.<p>I've put the WSGI app I used for this on github - hopefully someone finds it useful! <a href="https://github.com/mikery/s3cacher" rel="nofollow">https://github.com/mikery/s3cacher</a>