Amazon CloudFront is a content delivery network (CDN) that caches content at edge locations to improve response times for users. However, when you update your backend origin (such as an S3 bucket or an EC2 instance), CloudFront does not automatically update its cache. Instead, it continues serving cached content until the Time-to-Live (TTL) expires.
While TTL-based expiration works in many cases, sometimes you want the latest content to be available immediately. This is where cache invalidation comes into play.
Cache invalidation allows you to forcefully refresh specific files or entire paths in CloudFront before the TTL expires. This ensures that users always get the most up-to-date content without waiting for the cache to expire naturally.
/images/To force CloudFront to fetch fresh files, you need to invalidate specific paths: