asp.net - AWS 对象失效 -/如何确定图像是否从 Edge 中删除

标签 asp.net amazon-web-services amazon-s3 amazon-cloudfront

我想要使根目录和 http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html#invalidation-specifying-objects 无效

它说我们可以使用通配符

假设我们有这样的路径

https://cdn_url/rootimage/first/1/type/1.png

https://cdn_url/rootimage/first/1/type/2.png

https://cdn_url/rootimage/first/2/type/1.png

https://cdn_url/rootimage/first/2/type/2.png

https://cdn_url/rootimage/second/1/type/1.png

https://cdn_url/rootimage/second/1/type/2.png

https://cdn_url/rootimage/second/2/type/1.png

https://cdn_url/rootimage/second/1/type/2.png

所以如果我写

 AmazonCloudFrontClient objClient = new AmazonCloudFrontClient(ConfigurationManager.AppSettings["s3accesskey"], ConfigurationManager.AppSettings["s3secret"]);
        objClient.CreateInvalidation(new CreateInvalidationRequest
        {
            DistributionId = ConfigurationManager.AppSettings["CDNDistributionId"],
            InvalidationBatch = new InvalidationBatch 
            { 
                Paths = new Paths { Items = "/cdn_url/rootimage/*", Quantity = 1 } 
            }
        });

上面的代码可以工作吗? 那么“数量”是 1 还是所有实际图像的数量。

如何验证失效是否已完成。

我也在门户上手动尝试过,几分钟后我看到它说失效已完成,我如何确定图像是否已从 Edge 中删除。

谢谢

最佳答案

经过大量挖掘,看来,

可以使用图像标题响应

Connection
keep-alive Date
Mon, 15 Feb 2016 09:54:40 GMT Etag
"8239143f88d513feb78b025c5d4e1da7" Last-Modified
Fri, 12 Feb 2016 05:32:30 GMT Server
AmazonS3 Via 1.1 cldfrontUrl.ddfds (CloudFront) X-Amz-Cf-Id NKGtNTaLYGepIJ9Vjc1xgtQGn4AuhukYutQBDtSRPIyTGBDwLcxXgA== X-Cache Miss from cloudfront

如果是这样

Miss from cloudfront // Object is not in edge..

Hit from cloudfront //Object is in edge..

关于asp.net - AWS 对象失效 -/如何确定图像是否从 Edge 中删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35332759/

相关文章:

amazon-web-services - AWS Bucket策略错误: Policy has invalid action

image - Amazon S3 中合理的文件命名

ruby-on-rails-3 - 回形针图像大小符号

c# - 如何在 C# 中将鼠标单击事件添加到 Web TextBox

linux - 遍历命令并在 bash 中执行

c# - 是否有类似于 Twitter Bootstrap/Foundation5 的实用程序用于 Visual Studio 中的 WPF 文件?

amazon-web-services - 用户 CloudFormer 所需的权限

amazon-web-services - 用于复制到 Redshift 的 Java sdk

asp.net - 不能将 Asp.net core 2.0 与 Entity Framework 6 一起使用

asp.net - Azure站点: Compiler Error Message: CS1056: Unexpected character '$'