Dukeatcoding
Dukeatcoding

Reputation: 1393

Does changing Cloudfront Download Distribution Origin Path result in a cache invalidation?

I am working on a solution to get S3 and Cloudfront in sync when I upload a new version of an angular app.

My approach is to upload the new version to a new folder with an increasing version number http://awsbucket/v1 ... /v2 and after that updating the Download Distribution Origin Path to that new folder.

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesOriginPath

I am wondering if this change of the Origin Path automatically results in a complete cache invalidation or if i have to send invalidation requests never the less.

Upvotes: 2

Views: 1517

Answers (2)

Nicholas
Nicholas

Reputation: 149

To answer your question, NO - changing the Origin, including just the path, does not result in cache invalidation.

Information can be found here https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesDomainName

Quoting the specific part:

Changing the origin does not require CloudFront to repopulate edge caches with objects from the new origin. As long as the viewer requests in your application have not changed, CloudFront will continue to serve objects that are already in an edge cache until the TTL on each object expires or until seldom-requested objects are evicted.

Upvotes: 0

Naveen Vijay
Naveen Vijay

Reputation: 16492

So if you keep moving your web resources ( images, scripts or any thing that can be sent over http) to various versions and do to necessary changes in your app; by design; intentionally you would starting using the newer versions resources - the older version's cache would go colder and colder and eventually being taken out of the cache.

The invalidation requests are costly, time consuming while the versioning is easy and natural. The best use cases was found in the areas of newer CSS stylesheets, updation in js scripts being versioned. The same can be extrapolated for your use case.

Also you don't need to change the origin; keep adding the new files to the S3 and ensure the same are being reflected in the app- that would do.

Upvotes: 2

Related Questions