I have a S3 Bucket which contains index.html
, index.js
, and index.css
; a static website.
I am using CloudFront to distribute this S3 Bucket.
I am using a combination of CodePipeline and CodeBuild to update the files in my S3 bucket.
With this setup - it is possible for people to be seeing old versions of my website. One thing I can do is set up a Lambda which invalidates the cached S3 Bucket in CloudFront when CodePipeline and CodeBuild updates the files in the S3 Bucket.
The problem with this is that it is expensive so I am looking for an alternative.
One solution that I've thought of is to introduce a directory structure in my S3 bucket like so:
v1
|
_ index.html
_ index.js
_ index.css
v2
|
_ index.html
_ index.js
_ index.css
...
With this setup, is it possible to make CloudFront point to the latest version of my website rather? This would be cheaper than cache invalidation.