nerdexam
Amazon

DVA-C02 · Question #455

A developer hosts a static website on Amazon S3 and connects the website to an Amazon CloudFront distribution. The website uses a custom domain name that points to the CloudFront URL. The developer ha

The correct answer is C. Invalidate the file caches for the primary CloudFront distribution.. CloudFront serves cached versions of objects even after the S3 origin is updated; creating an invalidation forces CloudFront to fetch the latest files from S3.

Submitted by amina.ke· Mar 5, 2026Deployment

Question

A developer hosts a static website on Amazon S3 and connects the website to an Amazon CloudFront distribution. The website uses a custom domain name that points to the CloudFront URL. The developer has set up a continuous integration and continuous delivery (CI/CD) pipeline. The pipeline automatically runs when changes occur in an AWS CodeCommit repository. The pipeline has a source stage and then a build stage. The build stage invokes an AWS CodeBuild project that references a buildspec.yml file. The buildspec.yml file builds the code and deploys the static files to the S3 bucket. The pipeline runs successfully, and the latest website files are visible in the S3 bucket and at the S3 website URL. However, when the developer accesses the website through the CloudFront domain, the updates are not reflected on the website. What should the developer configure the buildspec.yml file to do to resolve this issue?

Options

  • AProperly synchronize the objects in the S3 bucket with new files from the source stage.
  • BDelete the previous website files in the S3 bucket and redeploy the website files.
  • CInvalidate the file caches for the primary CloudFront distribution.
  • DModify the cross-origin resource sharing (CORS) policy of the S3 bucket and redeploy the

How the community answered

(40 responses)
  • A
    5% (2)
  • B
    10% (4)
  • C
    80% (32)
  • D
    5% (2)

Why each option

CloudFront serves cached versions of objects even after the S3 origin is updated; creating an invalidation forces CloudFront to fetch the latest files from S3.

AProperly synchronize the objects in the S3 bucket with new files from the source stage.

The S3 bucket already contains the updated files as confirmed by the S3 website URL working correctly; a sync operation would not change the CloudFront caching behavior.

BDelete the previous website files in the S3 bucket and redeploy the website files.

Deleting and redeploying the website files does not address the CloudFront cache; the old cached versions would still be served until invalidated or expired.

CInvalidate the file caches for the primary CloudFront distribution.Correct

CloudFront caches objects at edge locations based on the cache TTL. When new files are uploaded to S3, CloudFront continues to serve the old cached versions until they expire. Creating a cache invalidation (e.g., for /*) instructs CloudFront to purge the cached objects and retrieve fresh copies from the S3 origin on the next request.

DModify the cross-origin resource sharing (CORS) policy of the S3 bucket and redeploy the

CORS policies control cross-origin resource sharing for browser requests; they are unrelated to CloudFront caching stale content after a deployment.

Concept tested: CloudFront cache invalidation after S3 origin updates in CI/CD

Source: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html

Community Discussion

No community discussion yet for this question.

Full DVA-C02 Practice