AWS website served via S3: configure cache
Aug 18, 2024
Add the “cache-control” to the “aws s3 cp” command
aws s3 cp static/ s3://YOUR_BUCKET/
--recursive --cache-control max-age=31536000
And test from the S3 console with any file, from S3 object actions panel
Wipe the cloudfront cache
aws cloudfront create-invalidation --distribution-id <YOUR_DIST> --paths "/*"
Then you can test via curl
/ $ curl -I https://YOUR_BUCKET_URL/file.css | grep cache
cache-control: max-age=31536000
x-cache: Hit from cloudfront