版本控制如何在Amazon Cloudfront上工作? [英] How does versioning work on Amazon Cloudfront?

查看:80
本文介绍了版本控制如何在Amazon Cloudfront上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在Amazon S3上建立了一个静态网站.我也在使用Cloudfront CDN服务.

I've just set up a static website on Amazon S3. I'm also using the Cloudfront CDN service.

根据Amazon,有两种清除Cloudfront缓存的方法:无效和版本控制.我的问题是关于后者.

According to Amazon, there are 2 methods available for clearing the Cloudfront cache: invalidation and versioning. My question is regarding the latter.

请考虑以下示例:

我从我的 index.html 文件链接到图像文件( image.jpg ).然后,我决定替换图像.我上传了第二个图像,文件名为: image_2.jpg ,并更改了 index.html 文件中的链接.

I link to an image file (image.jpg) from my index.html file. I then decide to replace the image. I upload a second image with the filename: image_2.jpg and change the link in my index.html file.

更改将自动生效还是需要采取进一步的措施?

Will the changes automatically take effect or is some further action required?

如果编辑后的文件和新上传的文件位于存储桶中而不是缓存中,什么触发了必要的更改?

What triggers the necessary changes if the edited and newly uploaded files are located in the bucket and not the cache?

推荐答案

CloudFront中的版本仅不过是在对象名称或存储对象的文件夹"名称中添加(或添加前缀)版本.

Versioning in CloudFront is nothing more than adding (or prefixing) a version in the name of the object or 'folder' where objects are in stored.

  • 文件夹 v1 中的所有对象,并使用如下网址 https://xxx.cloudfront.net/v1/image.png
  • 所有对象的名称都包含一个版本,例如image_v1.png,并使用一个URL,例如 https://xxx.cloudfront.net/image_v1.png
  • all objects in a folder v1 and use a URL like https://xxx.cloudfront.net/v1/image.png
  • all objects contain a version in their name like image_v1.png and use a URL like https://xxx.cloudfront.net/image_v1.png

第二个选项通常需要更多的工作,但是您不需要上传不需要更新的新文件(在存储环境中更便宜).第一个解决方案通常更清晰,需要的工作更少.

The second option is often a bit more work but then you don't need to upload new files which do not require to be updated (=cheaper in the context of storage). The first solution is often more clear and requires less work.

使用CloudFront版本控制需要更多的S3存储空间,但通常比创建许多失效更为便宜.

Using CloudFront Versioning requires more S3 storage but is often cheaper than creating many invalidations.

使缓存无效的另一种方法是创建无效(可能会很昂贵).如果您确实不需要无效,而只需要更快速地刷新缓存(默认为24h),则可以更新原始TTL设置(原始级别)或设置单个对象的缓存持续时间(对象级别).

The other way to invalidate the cache is to create invalidations (can be expensive). If you don't really need invalidations but just need more quick cache refreshes (default 24h) then you can update the origin TTL settings (origin level) or set cache duration for an individual object (object level).

这篇关于版本控制如何在Amazon Cloudfront上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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