如何快速更新谷歌云存储上的静态站点? [英] How to Quickly Update Static Site on Google Cloud Storage?

查看:15
本文介绍了如何快速更新谷歌云存储上的静态站点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个托管在谷歌云存储上的静态网站.我按照此处描述的相同方法进行设置:

I have a static site hosted on google cloud storage. I set it up per the same methodology described here:

https://cloud.google.com/storage/docs/hosting-静态网站

我已经购买了一个域名,并且该网站此时在其上运行良好.我仍在对网站内容进行更改.我当前的工作流程是在我的 windows 机器上本地编辑文件(例如 index.html),然后使用在线控制台/存储浏览器 https://console.cloud.google.com/storage/browser,确保将它们设置为公共链接.然后我使用 chrome 导航到我的网站以查看发生了哪些变化.

I have purchased a domain, and the website is running smoothly on it at this point. I am still in the process of making changes to the content of the site. My current workflow is to edit the files (for example, index.html) locally on my windows machine, and then upload the modified files to my storage bucket using the online console/ storage browser at https://console.cloud.google.com/storage/browser, making sure to set them as public links. I then navigate to my website using chrome to see what changes have occurred.

大多数时候,当我这样做时,我的网站似乎没有改变!我什至可以检查该站点的源文件,发现它们与我存储桶中当前的文件不匹配.如果我等待一段时间,从几分钟到几小时不等,网站最终会改变.我希望它可以立即更改,以便我可以快速测试更改(我无法在本地测试,因为我使用的框架在不运行本地主机的情况下无法运行,而我无法做到).如何让我的云存储静态站点快速更新?

Most of the time, when I do this, my site appears to be unchanged! I can even inspect the source files for the site and discover that they do not match the files that are currently in my storage bucket. If I wait some time, varying from minutes to hours, the website does eventually change. I would like it to be the case that it changes instantly so I can test changes quickly (I cannot test locally because the framework I am using does not function without running a localhost, which I cannot do). How do I do make my cloud storage static site update quickly?

对于可能发生这种情况的原因,我的最佳猜测非常分散.世界各地的各种gcp服务器同步在一起需要一些时间吗?它与我的域名注册商上的 TTL 设置或其他设置有什么关系吗?(namecheap,目前使用默认值).

My best guess for the reasons this might happen are pretty scattershot. Is it that it takes some amount of time for various gcp servers around the world to sync together? Would it have anything to do with the TTL settings or other settings on my domain name registrar? (namecheap, currently using defaults).

推荐答案

虽然在 GCS 基础架构内传播更改以解释您提到的行为并非不可能.

While it's not impossible for the propagation of the changes inside the GCS infrastructure to account for the behaviour you mention it's rather unlikely.

您更有可能看到缓存效果.可能发生的情况:

It's more likely you're looking at a cache effect. Which can happen:

  • 在 Google 云中:
    • inside the Google cloud:
      • work around it using a made up extra URL query parameter, like ?ignoreCache=1, see https://stackoverflow.com/a/37124554/4495081, or
      • see Cache-Control and Editing object metadata if you want a more permanent solution (but which also affects your site's performance, so think twice about what you're doing)

      这篇关于如何快速更新谷歌云存储上的静态站点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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