【问题标题】:Why does Google Cloud Storage not send correct cache headers?为什么 Google Cloud Storage 不发送正确的缓存标头?
【发布时间】:2019-11-02 21:20:59
【问题描述】:

我在 Google Cloud Storage 中有一些图像,我想通过标准浏览器缓存进行缓存。所以,我在文件对象元数据字段中写道:

Cache-control : public, max-age=300, no-transform

但是当我通过生成的 URL 获取图像时,缓存标头会显示:

cache-control: no-cache, no-store, max-age=0, must-revalidate

为什么会发生,我该如何解决?

Headers from browser screenshot

Metadata form in Google Cloud Storage screenshot

【问题讨论】:

    标签: google-cloud-platform google-cloud-storage


    【解决方案1】:

    documentation 中所述,只有公开的对象才能被缓存:

    Cache-Control 仅适用于具有公共读取 ACL 的对象。 非公开数据不可缓存。

    即使对象不是公开的,您也可以设置 Cache-Control 元数据,但不会有任何效果。

    【讨论】:

    • 我的对象是公开的,但我使用了错误的链接。
    【解决方案2】:

    好的,我解决了这个问题。 Google 对象有 2 个访问链接。您可能会在屏幕截图中看到正确的链接。以前,我使用“链接 URL”部分的链接。

    两个链接的区别在于它是一个请求服务器:

    我很困惑,但我没有看到小链接按钮,如此接近大“链接 URL”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-13
      • 1970-01-01
      • 2014-01-18
      • 1970-01-01
      相关资源
      最近更新 更多