How to resolve CloudFront serving outdated S3 content?

A developer manages a website that distributes its content by using Amazon CloudFront. The website's static artifacts are stored in an Amazon S3 bucket. The developer deploys some changes and can see the new artifacts in the S3 bucket. However, the changes do not appear on the webpage that the CloudFront distribution delivers. How should the developer resolve this issue?

  1. Configure S3 Object Lock to update to the latest version of the files every time an S3 object is updated.
  2. Configure the S3 bucket to clear all old objects from the bucket before new artifacts are uploaded.
  3. Set CloudFront to invalidate the cache after the artifacts have been deployed to Amazon S3. Source Reference Answer
  4. Set CloudFront to modify the distribution origin after the artifacts have been deployed to Amazon S3.

Community Votes

C
100%

100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.

Community Insight

This question tests the understanding of Content Delivery Network (CDN) caching behavior and the specific mechanism required to force a refresh, contrasting it with S3 configuration options that do not affect the CDN's edge cache.

When content in an S3 origin is updated, CloudFront may continue serving cached versions until the cache expires or is invalidated. The community agrees that creating a CloudFront invalidation is the necessary step to force an immediate update of the cached files.

Selecting option B (clearing old objects) is a common mistake because managing S3 storage does not trigger CloudFront to refresh its edge caches, which operate independently of the origin's file history.

Community Discussion (4 comments)

preachr 👍 1 Selected: C
When a user requests content from a website, CloudFront checks if the content is available in its cache. If the content is available in the cache, CloudFront delivers the content to the user from its cache. This speeds up the delivery of the content and reduces the load on the website’s servers. However, if the content has changed on the website, the cached content in CloudFront will be outdated. To ensure that users receive the latest content, the cached content in CloudFront needs to be invalidated. This means that the cached content is removed from the CDN, and the next time a user requests the content, it is fetched from the website’s servers.
albert_kuo 👍 2 Selected: C
aws cloudfront create-invalidation --distribution-id EXAMPLE_DIST_ID --paths "/*"
komorebi 👍 2
C. Set CloudFront to invalidate the cache after the artifacts have been deployed to Amazon S3.
rdiaz 👍 2 Selected: C
By invalidating the CloudFront cache, you ensure that the latest artifacts in your S3 bucket are delivered to users, resolving the issue of outdated content being displayed.

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Expert Analysis

Why the Answer Is Correct

CloudFront caches content at edge locations to reduce latency. When files in the S3 origin are updated, the edge locations retain the old versions until the Time To Live (TTL) expires. Option C is correct because invalidating the cache explicitly tells CloudFront to remove the old files from the edge locations and fetch the updated versions from S3. This ensures users see the changes immediately rather than waiting for the cache to expire naturally.

Why the Other Options Are Wrong

Option A is incorrect because S3 Object Lock is designed to prevent objects from being deleted or overwritten for a fixed amount of time, which is unrelated to CloudFront caching. Option B is incorrect because manually clearing S3 objects before upload does not send a signal to CloudFront to purge its cache. Option D is incorrect because modifying the distribution origin is unnecessary when only the content within the existing origin has changed; this action could even disrupt service.

Community Comment Notes

Community comments strongly support option C, citing the specific AWS CLI command for creating invalidations. Commenters highlight that while caching improves performance, it creates a delay in content visibility. The consensus is that invalidation is the standard mechanism to resolve the discrepancy between the origin (S3) and the CDN (CloudFront).

Official Reference

Exam Strategy

Remember that CloudFront acts as a middle layer. If the origin changes but the user sees old data, the issue is almost always the cache. Always look for 'invalidation' as the solution for immediate updates, rather than changing origin settings or modifying S3 bucket policies.

Related Analysis

Practice All DVA-C02 Questions

Access 100 questions with complete answers and detailed explanations.

View Full DVA-C02 Practice Test →

← Back to DVA-C02 Study Guide