Reputation: 81
I perform CloudFront invalidation for updated object on AmazonS3 in order to keep it always up-to-date. Do I need to perform invalidation for deleted object to be removed from cache as soon, as possible?
Upvotes: 0
Views: 1055
Reputation: 179462
You do not "need" to do this, unless -- for some reason -- you are trying to be certain that the object is no longer accessible via Cloudfront.
An object that has been deleted from the origin (in this case, the origin is S3) will eventually be purged from the cache at any edge locations where it happens to still exist.
Since Cloudfront has no associated storage charges, it is difficult to think of any real benefit to you from invalidating an object that has been deleted from the origin, unless, as stated above, your intention is to make the object globally inaccessible from every Cloudfront edge location.
Note, however, that the consistency model for S3 offers only eventual consistency on both DELETE
requests and overwrite PUT
requests. This means that even though it is unlikely, a deleted object in S3 could be still accessible for some period of time after you delete it (or the old version of an object could still be accessible for a short time after you overwrite it with a new version). This is information you need to keep in mind when sending Cloudfront invalidations. While very unlikely, it's theoretically possible for an invalidation to be processed before the corresponding delete or update was globally consistent inside S3.
Upvotes: 2