问题描述
在文档中似乎看不到明显的答案。
I can't seem to see an obvious answer in the documentation.
当我在S3上更新文件并启用CloudFront时,S3是否向CloudFront发送无效信号?还是更新文件后需要自己发送?
When I update a file on S3 and I have CloudFront enabled, does S3 send an invalidation signal to CloudFront? Or do I need to send it myself after updating the file?
推荐答案
S3不会将任何无效信息发送到CloudFront。默认情况下,CloudFront将保留信息,直到在从原始位置检索数据时设置的高速缓存控制标头指定的最长时间(如果感觉很早,它可能会从高速缓存中删除项目)。
S3 doesn't send any invalidation information to CloudFront. By default CloudFront will hold information up to the maximum time specified by the Cache Control headers that were set when it retrieved the data from the origin (it may remove items from its cache earlier if it feels like it).
您可以通过创建失效批处理来使高速缓存条目失效。这将花费您钱:每月第一个1000个请求是免费的,但除此之外,每个请求的费用为$ 0.005-如果您每天使1000个文件失效,则每月将花费$ 150(除非您可以使用通配符功能)。您当然可以使用Amazon Lambda函数触发此事件以响应s3事件。
You can invalidate cache entries by creating an invalidation batch. This will cost you money: the 1st 1000 requests a month are free but beyond that it costs $0.005 per request - if you were invalidating 1000 files a day it would cost you $150 a month (unless you can make use of the wildcard feature). You can of course trigger this in response to an s3 event using an Amazon Lambda function.
另一种方法是在对象更改时使用不同的路径(实际上是分代缓存键)。同样,您可以在URL上附加查询参数,并在希望Cloudfront提取新副本时更改该查询参数(为此,您需要告诉CloudFront使用查询字符串参数-默认情况下会忽略它们)。
Another approach is to use a different path when the object changes (in effect a generational cache key). Similarly you could append a query parameter to the url and change that query parameter when you want cloudfront to fetch a fresh copy (to do this you'll need to tell CloudFront to use query string parameters - by default it ignores them).
如果您只进行很少(但较大)的更改,另一种方法是简单地创建一个新的Cloudfront发行版。
Another way if you only do infrequent (but large) changes is to simply create a new cloudfront distribution.
这篇关于Amazon S3是否将无效信号发送到CloudFront?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!