使Cloudfront控制台中的文件夹中的所有文件无效

时间:2023-01-14 11:17:26

I know cloudfront provides a mechanism to invalidate a file, but what if I want to invalidate all files in a specific folder ? The documentation mentions that I can't use wildcards to do this.

我知道cloudfront提供了一种使文件无效的机制,但是如果我想使特定文件夹中的所有文件无效呢?该文档提到我不能使用通配符来执行此操作。

Here's the instruction taken from the official documentation:

以下是官方文档中的说明:

You must explicitly invalidate every object and every directory that you want CloudFront to stop serving. You cannot use wildcards to invalidate groups of objects, and you cannot invalidate all of the objects in a directory by specifying the directory path.

您必须显式使您希望CloudFront停止提供的每个对象和每个目录无效。您不能使用通配符使对象组无效,也不能通过指定目录路径使目录中的所有对象无效。

3 个解决方案

#1


15  

Back in 2013, in a previous version of this answer, I wrote:

早在2013年,在这个答案的先前版本中,我写道:

You can't do this because "files" in cloudfront are not in "folders." Everything is an object and every object is independent.

你不能这样做,因为cloudfront中的“文件”不在“文件夹”中。一切都是对象,每个对象都是独立的。

At the time, that was entirely true. It's still true that everything is an object and every object is independent, but CloudFront has changed its invalidation logic. Keep reading.

当时,这是完全正确的。一切都是对象并且每个对象都是独立的,但CloudFront已经改变了它的失效逻辑。继续阅读。

At the time, this was also true, and again, to a certain extent, it still is:

当时,这也是事实,在某种程度上,它仍然是:

The cloudfront documentation mentions "invalidating directories," but this refers to web sites that actually allow a directory listing [when] the listing is what you want to invalidate, so this won't help you either.

cloudfront文档提到了“使目录无效”,但这指的是实际上允许目录列出的网站[何时]列表是您要使其无效的内容,因此这也无济于事。

However, times have changed significantly.

但是,时代发生了重大变化。

Technically, each object is still independent, and CloudFront does not really store them in hierarchical folders, but the invalidation interface has been enhanced, to support a left-anchored wildcard match. You can invalidate the contents of a "folder" or any number of objects that you can match with a wildcard at the end of the string. Anything that matches will be evicted from the cache:

从技术上讲,每个对象仍然是独立的,CloudFront并不真正将它们存储在分层文件夹中,但是增强了失效界面,以支持左锚定的通配符匹配。您可以使“文件夹”的内容或可以与字符串末尾的通配符匹配的任意数量的对象无效。任何匹配的内容都将从缓存中逐出:

To invalidate objects, you can specify either the path for individual objects or a path that ends with the * wildcard, which might apply to one object or to many, as shown in the following examples:

要使对象无效,您可以指定单个对象的路径或以*通配符结尾的路径,该路径可能适用于一个对象或多个对象,如以下示例所示:

/images/image1.jpg

/images/image1.jpg

/images/image*

/图像/图像*

/images/*

/图片/*

— http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html

- http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html

Nice enhancement. But is there a catch?

很好的增强。但是有捕获吗?

Other than the fact that an invalidation requires -- as always -- 10 to 15 minutes to complete under normal operations, the answer is no, there's not really a catch. The first 1,000 invalidation paths (formerly "requests," and a "request" was for a single object) you submit within a month are free; after that, there is a charge, but:

除了失效需要 - 一如既往 - 在正常操作下完成10到15分钟,答案是否定的,没有真正的问题。您在一个月内提交的前1,000个无效路径(以前称为“请求”和“请求”是单个对象)是免费的;之后,收费,但是:

The price is the same whether you're invalidating individual objects or using the * wildcard to invalidate multiple objects.

无论是使单个对象无效还是使用*通配符使多个对象无效,价格都是相同的。

— http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html#PayingForInvalidation

- http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html#PayingForInvalidation

Note that if you don't include the * at the end, then an invalidation for /images/ (for example) will only tell CloudFront to invalidate whatever single object your origin server returns for requests for /images/.

请注意,如果最后未包含*,则/ images /(例如)的失效将仅告知CloudFront使源服务器为/ images /的请求返回的任何单个对象无效。

The leading slash is documented as optional.

前导斜杠记录为可选。

#2


6  

As long as you want to invalidate a reasonable amount of objects, one of the easier ways I've found is to select the objects in Cyberduck, right click > select Info and click on Distribution tab and you can invalidate from there. Cyberduck will submit one invalidation request to your Cloudfront with the list of selected files.

只要您想要使合理数量的对象无效,我发现的一种更简单的方法是在Cyber​​duck中选择对象,右键单击>选择信息并单击分发选项卡,您可以从那里无效。 Cyber​​duck将使用所选文件列表向您的Cloudfront提交一个无效请求。

Cyberduck is open source too.

Cyber​​duck也是开源的。

使Cloudfront控制台中的文件夹中的所有文件无效

ps: not affiliated with the product in any way. Just listing an alternative.

ps:不以任何方式与产品挂钩。只是列出一个替代品。

#3


6  

As of 2015-05-25, you can invalidate using a wildcard. Ex: /* or /images/*

自2015-05-25起,您可以使用通配符进行无效。例如:/ *或/ images / *

It is also far less costly to do it this way, as something like /images/* counts as one object for invalidation, rather than being charged for the thousands of images in the /images directory.

这样做的成本也低得多,因为像/ images / *这样的东西算作失效的一个对象,而不是对/ images目录中的数千个图像收费。

http://aws.amazon.com/about-aws/whats-new/2015/05/amazon-cloudfront-makes-it-easier-to-invalidate-multiple-objects/

http://aws.amazon.com/about-aws/whats-new/2015/05/amazon-cloudfront-makes-it-easier-to-invalidate-multiple-objects/

#1


15  

Back in 2013, in a previous version of this answer, I wrote:

早在2013年,在这个答案的先前版本中,我写道:

You can't do this because "files" in cloudfront are not in "folders." Everything is an object and every object is independent.

你不能这样做,因为cloudfront中的“文件”不在“文件夹”中。一切都是对象,每个对象都是独立的。

At the time, that was entirely true. It's still true that everything is an object and every object is independent, but CloudFront has changed its invalidation logic. Keep reading.

当时,这是完全正确的。一切都是对象并且每个对象都是独立的,但CloudFront已经改变了它的失效逻辑。继续阅读。

At the time, this was also true, and again, to a certain extent, it still is:

当时,这也是事实,在某种程度上,它仍然是:

The cloudfront documentation mentions "invalidating directories," but this refers to web sites that actually allow a directory listing [when] the listing is what you want to invalidate, so this won't help you either.

cloudfront文档提到了“使目录无效”,但这指的是实际上允许目录列出的网站[何时]列表是您要使其无效的内容,因此这也无济于事。

However, times have changed significantly.

但是,时代发生了重大变化。

Technically, each object is still independent, and CloudFront does not really store them in hierarchical folders, but the invalidation interface has been enhanced, to support a left-anchored wildcard match. You can invalidate the contents of a "folder" or any number of objects that you can match with a wildcard at the end of the string. Anything that matches will be evicted from the cache:

从技术上讲,每个对象仍然是独立的,CloudFront并不真正将它们存储在分层文件夹中,但是增强了失效界面,以支持左锚定的通配符匹配。您可以使“文件夹”的内容或可以与字符串末尾的通配符匹配的任意数量的对象无效。任何匹配的内容都将从缓存中逐出:

To invalidate objects, you can specify either the path for individual objects or a path that ends with the * wildcard, which might apply to one object or to many, as shown in the following examples:

要使对象无效,您可以指定单个对象的路径或以*通配符结尾的路径,该路径可能适用于一个对象或多个对象,如以下示例所示:

/images/image1.jpg

/images/image1.jpg

/images/image*

/图像/图像*

/images/*

/图片/*

— http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html

- http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html

Nice enhancement. But is there a catch?

很好的增强。但是有捕获吗?

Other than the fact that an invalidation requires -- as always -- 10 to 15 minutes to complete under normal operations, the answer is no, there's not really a catch. The first 1,000 invalidation paths (formerly "requests," and a "request" was for a single object) you submit within a month are free; after that, there is a charge, but:

除了失效需要 - 一如既往 - 在正常操作下完成10到15分钟,答案是否定的,没有真正的问题。您在一个月内提交的前1,000个无效路径(以前称为“请求”和“请求”是单个对象)是免费的;之后,收费,但是:

The price is the same whether you're invalidating individual objects or using the * wildcard to invalidate multiple objects.

无论是使单个对象无效还是使用*通配符使多个对象无效,价格都是相同的。

— http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html#PayingForInvalidation

- http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html#PayingForInvalidation

Note that if you don't include the * at the end, then an invalidation for /images/ (for example) will only tell CloudFront to invalidate whatever single object your origin server returns for requests for /images/.

请注意,如果最后未包含*,则/ images /(例如)的失效将仅告知CloudFront使源服务器为/ images /的请求返回的任何单个对象无效。

The leading slash is documented as optional.

前导斜杠记录为可选。

#2


6  

As long as you want to invalidate a reasonable amount of objects, one of the easier ways I've found is to select the objects in Cyberduck, right click > select Info and click on Distribution tab and you can invalidate from there. Cyberduck will submit one invalidation request to your Cloudfront with the list of selected files.

只要您想要使合理数量的对象无效,我发现的一种更简单的方法是在Cyber​​duck中选择对象,右键单击>选择信息并单击分发选项卡,您可以从那里无效。 Cyber​​duck将使用所选文件列表向您的Cloudfront提交一个无效请求。

Cyberduck is open source too.

Cyber​​duck也是开源的。

使Cloudfront控制台中的文件夹中的所有文件无效

ps: not affiliated with the product in any way. Just listing an alternative.

ps:不以任何方式与产品挂钩。只是列出一个替代品。

#3


6  

As of 2015-05-25, you can invalidate using a wildcard. Ex: /* or /images/*

自2015-05-25起,您可以使用通配符进行无效。例如:/ *或/ images / *

It is also far less costly to do it this way, as something like /images/* counts as one object for invalidation, rather than being charged for the thousands of images in the /images directory.

这样做的成本也低得多,因为像/ images / *这样的东西算作失效的一个对象,而不是对/ images目录中的数千个图像收费。

http://aws.amazon.com/about-aws/whats-new/2015/05/amazon-cloudfront-makes-it-easier-to-invalidate-multiple-objects/

http://aws.amazon.com/about-aws/whats-new/2015/05/amazon-cloudfront-makes-it-easier-to-invalidate-multiple-objects/