Google Cloud Storage传播 [英] Google Cloud Storage propagation

查看:77
本文介绍了Google Cloud Storage传播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对Google Cloud Storage中的文件所做的更改要传播多长时间?

How long does it take for a change to a file in Google Cloud Storage to propagate?

我遇到了一个非常令人沮丧的问题,我更改了文件的内容,然后通过gsutil重新上传了文件,但是更改没有出现几个小时.是否有一种方法可以强制更改后的文件立即传播所有内容?

I'm having this very frustrating problem where I change the contents of a file and re-upload it via gsutil, but the change doesn't show up for several hours. Is there a way to force a changed file to propagate everything immediately?

如果我在Google Cloud Storage控制台中查看文件,它将看到新文件,但是如果我单击公共URL,则它是旧版本,在某些情况下是2个版本.

If I look at the file in the Google Cloud Storage console, it sees the new file, but then if I hit the public URL it's an old version and in some cases, 2 versions ago.

有没有设置的标题吗?

我尝试了gsutil -h "Cache-Control: no-cache" cp -a public-read MyFile,但没有帮助,但是旧文件可能需要在新的非缓存版本接管之前过期?

I tried gsutil -h "Cache-Control: no-cache" cp -a public-read MyFile and it doesn't help, but maybe the old file needs to expire before the new no-cache version takes over?

我卷曲了-我在文件上把它取回来:

I did a curl -I on the file and get this back:

HTTP/1.1 200 OK
Server: HTTP Upload Server Built on Dec 12 2012 15:53:08 (1355356388)
Expires: Fri, 21 Dec 2012 19:58:39 GMT
Date: Fri, 21 Dec 2012 18:58:39 GMT
Last-Modified: Fri, 21 Dec 2012 18:53:41 GMT
ETag: "66d820174d6de17a278b327e4c3e9b4e"
x-goog-sequence-number: 3
x-goog-generation: 1356116021512000
x-goog-metageneration: 1
Content-Type: application/octet-stream
Content-Language: en
Accept-Ranges: bytes
Content-Length: 160
Cache-Control: public, max-age=3600, no-transform
Age: 3449

尽管没有缓存,这似乎表明它将在一个小时内到期.

Which seems to indicate it will expire in an hour, despite the no-cache.

推荐答案

Google Cloud Storage提供了强大的数据一致性:写入完成后,从世界任何地方进行读取都将获取最新数据.

Google Cloud Storage provides strong data consistency: once a write completes, a read from anywhere in the world will get the most recent data.

但是,如果启用缓存(对于任何公共可读对象,默认情况下为true),则对该对象的读取将看到该对象的版本与该对象上指定的Cache-Control max-age一样旧.例如,如果您上传的文件是这样的:

However, if you enable caching (which by default is true for any publicly readable object), reads of that object can see a version of the object as old as the Cache-Control max-age specified on the object. If, for example, you uploaded the file like this:

gsutil cp -a public-read file gs://my_bucket/file

您可以看到最大寿命为1小时(3600秒):

You can see that the max-age is 1 hour (3600 seconds):

gsutil ls -L gs://my_bucket/file
gs://my_bucket/file:
    Creation time:  Fri, 21 Dec 2012 19:59:57 GMT
    Cache-Control:  public, max-age=3600, no-transform
    Content-Length: 1065
    Content-Type:   text/plain
    ETag:       eb3fb83beedf1efffe5b8e32e8d6a65a
    ...

如果要防止缓存公共可读对象,可以执行以下操作:

If you want to prevent a publicly readable object from being cached you could do:

gsutil setmeta -h Cache-Control:no-cache gs://my_bucket/file

或者,您可以在对象上设置一个较短的最大年龄:

Alternatively, you could set a shorter max-age on the object:

gsutil setmeta -h 'Cache-Control:public, max-age=600, no-transform'

Mike Schwartz,Google云存储团队

Mike Schwartz, Google Cloud Storage team

这篇关于Google Cloud Storage传播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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