Compress with gzip on firebase

2019-07-13 18:07发布

问题:

I'm trying to compress my .css and .js on my firebase hosted web to increase loading speeds, however I've been unable to use the firebase.json config file to correctly setup a gzip compression for my assets.

The curl -v command shows that no compression is performed when serving the files from the server. Also checked in the network section of Firefox Developer edition.

The furthest I've been able to go has been a load error on my browser because of my .json configuration.

"source": "**/*.@(jpg|jpeg|gif|png)",
"headers": [
  {
    "key": "Cache-Control",
    "value": "max-age=7200"
  },
  {
    "key": "Content-Encoding",
    "value": "gzip"
  }
]

This has been my try on the firebase settings resulting in the browser not loading any of the css nor the js.

Any thoughs?

Thanks!

回答1:

Firebase Hosting has a size threshold for compressing files.

All the files that were uncompressed were small (<1K), so they didn't meet that threshold.