【问题标题】:Firebase Hosting is caching my dynamic `robots.txt` on the CDNFirebase 托管正在 CDN 上缓存我的动态“robots.txt”
【发布时间】:2021-05-20 01:10:42
【问题描述】:

从 Firebase 文档中,我们了解到它应该将 Cache-Control: private 设置为默认值。

Firebase Hosting- Manage cache behavior

我即时生成我的robots.txt,因此它可能会从一个请求更改为下一个请求。因此,我不希望它被 CDN 缓存。但令我惊讶的是,robots.txt 的 CDN 命中率很高。

见:

我对@9​​87654329@ 和sitemap.xml 也是如此。 ads.txt 也是如此,但 sitemap.xml 则不然。

也许它与.txt 文件有关。这可能是一个错误吗?

我是否必须明确设置Cache-Control: private

【问题讨论】:

    标签: firebase caching cdn firebase-hosting robots.txt


    【解决方案1】:

    您可以像这样通过firebase.json 文件配置该特定文件的缓存控制标头:

    {
      "hosting": [
        {
          ...,
          "headers": [
            {
              "source": "robots.txt",
              "headers": [
                {
                  "key": "Cache-Control",
                  "value": "no-cache"
                }
              ]
            }
          ]
        }
      ]
    }
    

    更多信息请参阅文档here

    【讨论】:

      猜你喜欢
      • 2018-05-07
      • 2019-03-18
      • 2019-03-28
      • 2016-12-05
      • 2010-10-03
      • 2018-10-18
      • 2021-05-13
      • 2020-07-31
      • 2020-06-17
      相关资源
      最近更新 更多