A developer hosts a static website on Amazon S3 and serves it through CloudFront using a custom domain. A CI/CD pipeline (triggered by CodeCommit) runs a build stage that executes a CodeBuild project referencing a buildspec.yml. The build uploads updated static files to the S3 bucket and the updates are visible at the S3 website URL, but the CloudFront distribution still serves the old content. What should the buildspec.yml do to ensure CloudFront serves the updated files?
Choose an answer
Tap an option to check your answer.
Correct answer: Invalidate the cached objects for the CloudFront distribution so CloudFront fetches the updated files..
Why this is the answer
The correct answer is to invalidate cached objects for the CloudFront distribution. CloudFront caches content at edge locations to improve performance and reduce origin load. When you update files in your S3 bucket, CloudFront continues to serve the outdated cached versions until those caches expire or are explicitly invalidated. Invalidating the cache forces CloudFront to fetch the latest content from your S3 origin. Synchronizing S3 bucket objects or deleting and redeploying files addresses the S3 content but doesn't resolve CloudFront's caching behavior. Changing the S3 bucket's CORS configuration is unrelated to content updates or caching; it controls how web browsers handle cross-origin requests.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed