Rog*_*rat 28 google-cloud-storage
更改Google云端存储中的文件需要多长时间才能传播?
我有这个非常令人沮丧的问题,我改变文件的内容并通过gsutil重新上传,但更改不会显示几个小时.有没有办法强制更改文件立即传播所有内容?
如果我查看Google云端存储控制台中的文件,它会看到新文件,但如果我点击公共网址,那么它就是旧版本,在某些情况下,还有2个版本.
有没有我没有设置的标题?
编辑:
我试过gsutil -h "Cache-Control: no-cache" cp -a public-read MyFile,它没有帮助,但也许旧的文件需要在新的无缓存版本接管之前到期?
我在文件上做了一个curl -I并得到了回复:
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
Run Code Online (Sandbox Code Playgroud)
这似乎表明它将在一小时内到期,尽管没有缓存.
Mik*_*rtz 38
Google云端存储提供强大的数据一致性:写入完成后,从世界任何地方进行的读取都将获得最新数据.
但是,如果启用缓存(默认情况下对于任何公共可读对象都是如此),则对该对象的读取可以看到该对象的版本与对象上指定的Cache-Control max-age一样长.例如,如果您上传了这样的文件:
gsutil cp -a public-read file gs://my_bucket/file
Run Code Online (Sandbox Code Playgroud)
你可以看到max-age是1小时(3600秒):
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
...
Run Code Online (Sandbox Code Playgroud)
如果要阻止公共可读对象被缓存,您可以执行以下操作:
gsutil setmeta -h Cache-Control:no-cache gs://my_bucket/file
Run Code Online (Sandbox Code Playgroud)
或者,您可以在对象上设置更短的max-age:
gsutil setmeta -h 'Cache-Control:public, max-age=600, no-transform'
Run Code Online (Sandbox Code Playgroud)
Google云存储团队Mike Schwartz
| 归档时间: |
|
| 查看次数: |
4484 次 |
| 最近记录: |