Search code examples
cdnamazon-cloudfront

Remove file from CDN cache


I've uploaded a file in the s3 bucket and also I've added CDN caching for load files. I want to update that with the same name but the problem is that I can't get updated file. CDN return always old file because it's cached in CDN for 1 year (max-age:31536000).

So, how can I remove it from CDN?


Solution

  • You can invalidate the file as described at https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html. Invalidation instructs CloudFront to ignore the copy in its caches and instead contact the origin server.