Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a huge bucket of photos on s3. We add and remove from this daily but it currently has millions of photos that we don't want to rewrite or update if possible.

We have not set any expires headers on these existing photos.

I just Spun up cloudfront and pointed it to our bucket.

I have two goals now:

  1. Use versioning to let older photos expire from Cloudfront.
  2. Set Far Future Expire headers somewhere (S3, CloudFront) to inform browsers they should keep these files forever.

This raises a few questions. Can I accomplish both goals above with one setting?

Can I make this setting(s) at a bucket level, an individual photo level, or at the cloudfront level.

It would be preferable to be able to make any cache and far future expires header settings at the cloudfront or S3 bucket level and not worry about these settings on an individual photo level, especially in light of the fact that we have millions of photos without these settings already in s3.

thnks for any help, much appreciated!

share|improve this question
up vote 0 down vote accepted

You add a cache-control unfortunately, at the individual item level within S3. I don't know if you can do this at the bucket level.

You can however do this for multiple items at once using a 3rd party tool, like CloudBerry Explorer

I have done this for some items, here's a screenshot from the AWS web console:

enter image description here

the value is in seconds.

S3 also supports versioning but I've not personally had a play with it.

In terms of Cloudfront, you'll only need to mess around with it to invalidate old versions of documents. i.e. you've changed the index.html file and you need Cloudfront to immediately delete it's (now) out of date copy. Invalidate the file, and users browsing the site will get the updated copy from S3.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.