简体   繁体   English

AWS CloudFront 仅使根目录中的对象无效

[英]AWS CloudFront Invalidate only objects in the root directory

Is there a way to invalidate only the objects at root level in a AWS CloudFront distribution.有没有办法仅使 AWS CloudFront 分配中根级别的对象无效。

Let's assume that I have the following distribution.假设我有以下分布。 I would like to be able to invalidate index.html , photo1.jpg , photo2.jpg , but not subdir/ and the files in it.我希望能够使index.htmlphoto1.jpgphoto2.jpg无效,但不能使subdir/和其中的文件无效。

index.html
photo1.jpg
photo2.jpg
subdir/
   photo3.jpg
   photo2.jpg

You can try invalidating by grouping file names into common prefixes.您可以尝试通过将文件名分组到公共前缀中来使无效。

In your example above, the following paths will work在上面的示例中,以下路径将起作用

  • /index* /指数*
  • /photo* /照片*

Unfortunately, Cloudfront requires the wildcard (*) to be at the end of the paths, so you can't invalidate by object extensions.不幸的是,Cloudfront 要求通配符 (*) 位于路径的末尾,因此您不能通过 object 扩展来使其无效。

Ref: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html#invalidation-specifying-objects-paths参考: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html#invalidation-specifying-objects-paths

This is not possible, the thing you can do is to invalidate files with certain prefix for example这是不可能的,您可以做的就是使具有特定前缀的文件无效,例如

/logo*

Will invalidate only files with that name and different extension like logo.png , logo.jpg , logo.gif , etc. But if you have a directory called logo it will be invalidated too只会使具有该名称和不同扩展名的文件(例如logo.pnglogo.jpglogo.gif等)失效。但是如果您有一个名为logo的目录,它也会失效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM