适用于所有存储桶的 Amazon S3 缓存控制 [英] Amazon S3 Cache-Control for all bucket
问题描述
我使用 Amazon S3 和 CloudFront.我有静态图片,用户下载图片(每小时 + 100 张图片).
I use Amazon S3 and CloudFront. I have static images and users downloaded images(every hour + 100 images).
我需要为所有存储桶设置 Cache-Control http 标头.
I need to set Cache-Control http header for all bucket.
我在谷歌搜索,但找不到任何说明,如何执行此操作.
I search in google, but I cant find any instruction, how to do this.
是的,我知道文件属性中的 MetaData,但我需要所有存储桶的 MetaData(+ 未来的新文件).
Yes, I know about MetaData in file Properties, but I need MetaData for all bucket (+ new files in future).
如果在亚马逊控制台无法做到,有没有开源的解决方案?
If it is not possible to do in Amazon console, is there any open source solutions?
谢谢!
推荐答案
S3 没有在现有或未来对象上设置全局存储桶元数据的机制.您的代码需要在创建对象时设置此项.
S3 does not have a mechanism for setting global bucket metadata on existing or future objects. Your code needs to set this when the objects are created.
您可以使用放置/复制"将其添加到现有对象中.API 的操作,允许您使用修改后的元数据将对象复制到自身上,而无需实际下载和重新上传对象.
You can add it to existing objects using the "put/copy" operation of the API, which allows you to copy an object onto itself, with modified metadata, without actually downloading and re-uploading the object.
http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectCOPY.html
关于开源解决方案,可能有,但他们可以使用的唯一可能机制是执行相同的操作 - 遍历存储桶并通过 API 更新每个对象的元数据.不过无论如何:
Regarding open-source solutions, there might be, but the only possible mechanism they could use would be to perform the same actions -- iterating through the bucket and updating each object's metadata via the API. In any event, though:
要求我们推荐或查找书籍、工具、软件库、教程或其他场外资源的问题对于 Stack Overflow 来说是无关紧要的,因为它们往往会吸引自以为是的答案和垃圾邮件.
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam.
— https://stackoverflow.com/help/on-topic
这篇关于适用于所有存储桶的 Amazon S3 缓存控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!