We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

CloudFront Invalidation

A CDN is a geographically distributed cache, which means it's one of the hardest things to deal with...

"There are 2 hard problems in computer science: cache invalidation, naming things, and off-by-1 errors."

– Leon Bambrick

If you update the favicon in your S3 bucket, it won't immediately update for users accessing it through CloudFront.

Similarly, if you use CloudFront to serve content like HTML, CSS, or JavaScript files for a website, users might not see the latest version of your site immediately after you make changes.

For that reason, you need to know how to invalidate cached content in CloudFront. This forces CloudFront to fetch the latest version from the origin (your S3 bucket) instead of serving the cached version. It basically says:

"Hey! There's new content, go update the cache!"

Assignment

PatientPing has gone stylish. Marketing wants to use a new black and white version of the logo.

Upload the new logo to S3 and invalidate the CloudFront distribution cache so that users see the new logo immediately.

  1. curl -o favicon.ico https://storage.googleapis.com/qvault-webapp-dynamic-assets/course_assets/patientping-bw-favicon.ico
    

The CLI tests check CloudTrail for your invalidation event. CloudTrail events can take a few minutes to appear, so wait 2-5 minutes after the invalidation completes before submitting.

Run and submit the CLI tests.

Tip

If you prefer to use the CLI, here is the command structure:

aws cloudfront create-invalidation \
  --distribution-id YOUR_DISTRIBUTION_ID \
  --paths "/favicon.ico"