Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Hosting: cache busting scripts on deploy

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

like image 422
user3240644 Avatar asked Dec 23 '22 21:12

user3240644


1 Answers

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

like image 140
TMan Avatar answered Dec 28 '22 11:12

TMan