Firebase托管:在部署时缓存破坏脚本

问题描述 投票:3回答:1

我在firebase上托管了一个Polymer(单页面应用程序)应用程序。当我将新版本部署到firebase时,我希望firebase重新加载javascript源代码而不是使用缓存源代码。是否有可能通过firebase.json这样做?如果是这样,怎么样?或者我是否必须手动将缓存清除URL添加到我的构建输出中?谢谢

firebase firebase-hosting
1个回答
11
投票

将Webpack或类似工具添加到构建中可能是最简单的方法,因为目前还没有办法直接使用Firebase获得所需的结果:

How Can I Make Webpack Use a Cache-Busting Suffix?

如果您可以完全删除缓存,只需为firebase.json中不需要缓存的文件设置相关标头:

{
  ...
  "headers": [{
      "source": "build.js",
      "headers": [{
        "key": "Cache-Control",
        "value": "max-age=0"
      }]
  }],
  ...
}

有关详细信息,请参见此处:https://firebase.google.com/docs/hosting/full-config#headers

© www.soinside.com 2019 - 2024. All rights reserved.