Amazon S3静态Web托管缓存 [英] Amazon s3 static web hosting caching

查看:111
本文介绍了Amazon S3静态Web托管缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Amazon S3虚拟主机用于我的静态html,js,css(等)文件. 替换index.html文件后,在通过浏览器进行消费时,我仍然获得旧版本. 我想将默认ttl设置为存储桶(而不是存储桶中的特定对象).我找到了此链接: http://docs.aws.amazon .com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesDefaultTTL

I'm using Amazon S3 webhosting for my static html,js,css (etc..) files. After replacing my index.html file, I still get the old version when consuming via the browser. I would like to set a default ttl to the bucket (and not to specific objects in it). I found this link: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesDefaultTTL

,但无法在信息中心中找到对象缓存"设置.有人可以指出它在哪里吗?

but can't find the "Object Caching" setting in the dashboard. can someone point out where it is?

推荐答案

这是一个 BucketExplorer 了解更多信息.

Here's an Amazon S3 link that answers your question. According to Amazon, you can't set the cache control header for the entire bucket unless you use a third party tool (that page links to a few). One tool I ran across describes how to set the cache directives for objects submitted using a PUT request (or in bulk using their tool). See BucketExplorer for more info.

以下是Amazon指令的摘要(因为S.O.不喜欢依赖可能更改或消失的外部链接):

Here is a cut-paste of Amazon's instructions (since S.O. doesn't like to rely on external links that might change or disappear):

使用Amazon S3控制台将Cache-Control或Expires标头字段添加到Amazon S3对象

  1. 登录到AWS管理控制台并打开Amazon S3控制台 在 https://console.aws.amazon.com/s3 .
  2. 在Amazon S3控制台的存储桶窗格中,单击包含文件的存储桶的名称.
  3. 在对象列表中,选择要向其添加标题字段的第一个对象.
  4. 点击操作,然后点击属性.
  5. 在右窗格中,展开元数据.
  6. 点击添加更多元数据.
  7. 密钥列表中,单击缓存控制过期(如果适用).
  8. 字段中,输入适用的值:
  9. 对于缓存控制"字段,输入:max-age=number of seconds that you want objects to stay in a CloudFront edge cache
  10. 对于 Expires (到期时间)字段,以HTML格式输入日期和时间.
  11. 点击保存.
  1. Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3.
  2. In the Amazon S3 console, in the buckets pane, click the name of the bucket that contains the files.
  3. In the list of objects, select the first object to which you want to add a header field.
  4. Click Actions and click Properties.
  5. In the right pane, expand Metadata.
  6. Click Add More Metadata.
  7. In the Key list, click Cache-Control or Expires, as applicable.
  8. In the Value field, enter the applicable value:
  9. For a Cache-Control field, enter: max-age=number of seconds that you want objects to stay in a CloudFront edge cache
  10. For an Expires field, enter a date and time in HTML format.
  11. Click Save.

如果要将标题字段添加到其他对象,请单击下一个对象的名称,然后重复步骤5到9.

If you want to add a header field to additional objects, click the name of the next object, and repeat steps 5 through 9.

这篇关于Amazon S3静态Web托管缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆