How to make CloudFront never cache index.html on S3 bucket

A solution based on CloudFront configuration:

Go to your CloudFront distribution, under the "Behavior" tab and create a new behavior. Specify the following values:

  • Path Pattern: index.html
  • Object Caching: customize
  • Maximum TTL: 0 (or another very small value)
  • Default TTL: 0 (or another very small value)

Save this configuration.

CloudFront will not cache index.html anymore.


If you never want index.html to be cached, set the Cache-Control: max-age=0 header on that file only. CloudFront will make a request back to your origin S3 bucket on every request, but it sounds like this is desired behavior.

If you're wanting to set longer expiry times and invalidate the CloudFront cache manually, you can use a * or /* as your invalidation path (not / as you have mentioned). This can take up to 15 minutes for all CloudFront edge nodes around the world to reflect the changes in your origin however.