简体   繁体   English

多次更新/删除后,Google Cloud Storage文件卡在时间上

[英]Google Cloud Storage file stuck in time after multiple updates/deletions

I have a cloud storage file frozen in time and will not budge. 我有一个及时冻结的云存储文件,不会让步。 So far I have: 到目前为止,我有:

  • recollected static files (Django) and did an rsync to update 重新收集了静态文件(Django)并进行了rsync更新

  • deleted the static file in question, recollected static files and did an rsync to update 删除有问题的静态文件,重新收集静态文件并进行rsync更新

  • deleted the file in the cloud storage console and re-rsynced 删除了云存储控制台中的文件并重新同步

  • deleted the entire bucket and made another bucket with the same name, and rsynced all 85 static files onto it again 删除整个存储桶,并创建另一个具有相同名称的存储桶,然后再次将所有85个静态文件同步到该存储桶

The first few times I changed the static file, collected them, and rsynced, it worked instantly. 头几次,我更改了静态文件,收集了它们,并进行了同步,它立即起作用。 Now I have this one line 现在我有这条线

var URL = "http://%/api/recipes/delete/&/".replace("%", API_BASE).replace("&", recipe_id);

stuck in time, frozen in this bucket. 卡在时间上,冻结在这个桶里。 In Django, my file correctly reads 在Django中,我的文件正确读取

var URL = "/api/recipes/delete/&/".replace("&", recipe_id);

The change is checked into git. 更改签入git。

This storage API has not updated at all, and the file was still being served even after I deleted the file. 此存储API根本没有更新,即使删除了文件,文件仍在提供中。 The file was still being served after I deleted the entire bucket, which seems like a bug. 删除整个存储桶后,文件仍在提供服务,这似乎是一个错误。 The file is: 该文件是:

http://storage.googleapis.com/homebrew-api-static-bucket/static/main/index.js http://storage.googleapis.com/homebrew-api-static-bucket/static/main/index.js

Yet if I view the file from the Cloud Storage console, I get the correct file. 但是,如果我从Cloud Storage控制台查看文件,则会得到正确的文件。

So even though the file is correct in the bucket, the file my app uses is still outdated after over 2 hours 因此,即使文件桶中的文件正确无误,但我的应用使用的文件在2个多小时后仍然过时

I serve the file in index.html like: 我在index.html提供文件,例如:

<script src="{% static "main/index.js" %}" type='text/javascript'></script>

In settings.py : settings.py

STATIC_ROOT = os.path.join(BASE_DIR, 'static')

STATIC_URL = 'http://storage.googleapis.com/homebrew-bucket/static/'

I'm out of ideas if even deleting and remaking the entire bucket doesn't change anything. 即使删除和重新制作整个存储桶也不会改变任何东西,我还是没有主意。

GCS provides strong read-after-write consistency. GCS提供了强大的写入后读取一致性。 If you upload a new version of an object and then download it back, you will always get the new version of the object. 如果您上传了对象的新版本,然后又将其下载回去,则将始终获得该对象的新版本。

However, by default, when a publicly readable object is fetched, GCS responds with a "Cache-Control" header allowing caching for up to 1 hour. 但是,默认情况下,当获取公共可读对象时,GCS会以“ Cache-Control”标头响应,最多允许缓存1小时。 Google itself, your web browser, or some firewall between you and Google may decide based on that header to cache your object. Google本身,您的Web浏览器或您与Google之间的某些防火墙可能会根据该标头决定缓存对象。 You can check to see if this is the problem by fetching the object again and tacking some bogus URL parameter onto the end of the request, like "?avoidTheCaches=1". 您可以通过再次获取对象并在请求的末尾添加一些虚假的URL参数,例如“?avoidTheCaches = 1”,来检查是否是问题所在。

You can prevent this from happening by setting the object's "cacheControl" property to something like "private" or "max-age=0". 您可以通过将对象的“ cacheControl”属性设置为“ private”或“ max-age = 0”之类的方法来防止这种情况的发生。 You can set this property as part of an upload. 您可以将此属性设置为上传的一部分。 You can also modify the property for an existing object, but if the resource has already been cached, you'll have to wait out the hour before you'll see the new version. 您还可以修改现有对象的属性,但是如果资源已被缓存,则必须等待一个小时,然后才能看到新版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM