Firebase Hosting: cache busting scripts on deploy

邮差的信 提交于 2019-12-06 07:08:09

问题


I have a Polymer (single page app) application hosted on firebase. When I deploy a new version to firebase, I'll like firebase to reload the javascript source instead of using cached ones. Is it possible to do that via firebase.json? If so, how? Or do i have to manually add a cache busting url to my build output? Thanks


回答1:


Adding Webpack or a similar tool to your build is probably the easiest way to go, as there's not currently a way to achieve the desired result with Firebase directly:

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

If you're okay removing the cache completely, you can simply set the related headers for the files you don't want cached in firebase.json:

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

See here for more details: https://firebase.google.com/docs/hosting/full-config#headers



来源:https://stackoverflow.com/questions/41711466/firebase-hosting-cache-busting-scripts-on-deploy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!