Replies: 1 comment 1 reply
-
|
What you are seeing is CloudFront caching an older response (including its headers) for
There is no “pre-warm / lock CloudFront until S3 metadata is correct” switch. The correct way to prevent this class of issue is to avoid reusing the same cache key for HTML, or force CloudFront to re-fetch on every request (or near every request). Practical fixes: Use cache-busting for HTML (recommended) Deploy aws s3 cp index.html s3://bucket/index.${GIT_SHA}.html --content-type text/html --cache-control "max-age=30" Then update the entry point to reference the new object (or use a rewrite/origin function). Or keep the name but make CloudFront stop caching it Set CloudFront behavior/cache policy for If you must keep the same key and need immediate correctness You must invalidate the CloudFront cache entry after upload: aws cloudfront create-invalidation --distribution-id <DIST_ID> --paths "/index.html" Summary: S3 metadata can be correct immediately, but CloudFront may serve a previously cached response with the old |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am facing this issue for some time now, it appears to be a delta between the copy and the actual set of content-type.
If one visits the domain associated with the bucket, in between that delta, then cloud front will server index.html as a text/plain and there would be no way to fix it without requesting cache invalidation + browser forced refresh + restart of browser.
Is there a way to ensure the proper content-type is set, prior to cloud-front accessing the object ?
Beta Was this translation helpful? Give feedback.
All reactions