New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use zopfli instead of zlib for improved gzip compression on upload #894
Comments
Thanks for the suggestion! This is something we could consider for the future, but there's a lot to unpack -- we use the content hash of the gzipped file to uniquely identify files, so any change to the gzip compression is going to mean losing the advantages of "change-only" uploads for everyone who switches to the new version. If the savings are significant, it's still worth considering, but it's not something we can just drop in. |
Sounds like opt-in would be the way to go then for something like this. The savings are generally pretty minimal (3-8% according to https://developers.googleblog.com/2013/02/compress-data-more-densely-with-zopfli.html), especially considering the upfront CPU cost. Another potential issue with zopfli is that it uses node-gyp, which can be problematic on Windows builds. Implementing Brotli in the future would provide much more savings (for browsers that support it), but there would have to be a change to the Firebase back-end to handle it (it used to be possible to serve brotli encoded text-based files from firebase hosting, but a recent serverside change broke this behavior). |
Brotli support is something that's on our radar, but no timeline to announce. |
@Memeriaj this would be a server-side feature right? If so should we close this issue here on |
gzipping is currently a client-side feature (or it was when I filed this issue). |
@davidmurdoch oops, I'll show myself out. |
@mbleigh any update on brotli support? |
@matthewharwood They used to support it by setting a They did say back in August that |
@davidmurdoch yeah heard something like this on Twitter too. Long shot but do you know any cdn that offers brotli without crazy lambda file rewrites on orgin? |
Cloudflare will do it and it's free. https://support.cloudflare.com/hc/en-us/articles/200168396-What-will-Cloudflare-compress- |
Brotli is available by default on static hosting content now: https://firebase.googleblog.com/2020/08/firebase-hosting-new-features.html |
@kmcnellis Thank you so much for tagging thihs issue. Firebase has always been my favorite static site hosting and now I can finally go back! |
I've forked firebase-tools to do this myselfhere: davidmurdoch@0afb596
Zopfli improves overall file size savings beyond what gzip at level 9 can do at the expense of extra CPU cycles at compression time.
In my branch I just default to using zopfli compression. But it could easily opt-in.
I'm also running with a relatively high number of zopfli iterations that may not be suitable for users with large file sizes. Defaulting to a lower number of iterations or just checking the uncompressed size of the file in order to choose an acceptable number of iterations may be a better choice.
The text was updated successfully, but these errors were encountered: