每当我对 S3 存储桶进行更改时,我的 CloudFront 都不会更新为新内容。我每次都必须创建一个失效才能看到新内容。是否有另一种方法可以让 CloudFront 在我将内容推送到我的 S3 存储桶时加载新内容?
最佳答案
让我在线回答您的问题。
Whenever I make a change to my S3 bucket my CloudFront doesn't update to the new content. I have to create an invalidation every time in order to see the new content.
是的,这是 CloudFront 中的默认行为,除非您已将 TTL 值定义为零 (0)。
Is there another way to make CloudFront load the new content whenever I push content to my S3 bucket?
您可以使用 AWS Lambda 自动执行失效。去做这个;
- 创建 S3 事件触发器以在您将任何新内容上传到 S3 时调用 lambda 函数。
- 在 Lambda 函数内,使用 AWS CloudFront SDK 编写代码使 CloudFront 分配失效 createInvalidation方法。
注意:确保 Lambda 函数具有 IAM 角色,该角色具有在 CloudFront 中触发失效的策略权限。
关于amazon-web-services - AWS CloudFront 未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53416462/