How to clear Amazon CloudFront Cache completely?

2019-04-18 14:25发布

I made some changes to my origin server which now serves different data from same url.

I tried to clear my cache completely by doing the following invalidation in CF UI:

enter image description here

But this didn't work. How can I wipe off completely the Amazon CloudFront cache's in one go?

3条回答
做个烂人
2楼-- · 2019-04-18 14:31

According to AWS documentation you need to use /* instead of /

查看更多
趁早两清
3楼-- · 2019-04-18 14:34

CloudFront does now support wildcard or full distribution invalidation. You will need do do one of the followng.

  • Invalidate each object that has changed
  • Invalidate /*
  • Version your objects so that they are considered new (Ie rename or querystring)

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html#invalidating-objects-console

查看更多
The star\"
4楼-- · 2019-04-18 14:54

You need to use /* instead of /.

Also, if you need to do this frequently, you can do it using the AWS CLI.

aws cloudfront create-invalidation --distribution-id=YOUR_DISTRIBUTION_ID --paths "/*"

Edit: thanks to @speckledcarp, you need to use "/*" (with quotes) when using the CLI.

Note: this command is still in preview phase, but you can use it if you enable preview running:

aws configure set preview.cloudfront true 
查看更多
登录 后发表回答