user3240644
user3240644

Reputation: 2281

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

Upvotes: 6

Views: 7688

Answers (1)

TMan
TMan

Reputation: 1905

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

Upvotes: 12

Related Questions