-
Notifications
You must be signed in to change notification settings - Fork 83
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
compress assets with brotli as well as gzip #71
Comments
Thanks for posting this this feature request.
Doing that has a trade-off of making the generated assets file roughly 2x larger. As a result, it might be preferable to make it an option (generate gzip only, generate Brotli only, generate both, and maybe some other combinations). This decision is worth thinking about more. I want to make sure there aren't some other unexpected implications when going from 1 compression algorithm to more than 1.
Oh, I didn't know a pure Go Brotli encoder exists by now, thank you for sharing that! (I was only aware of a pure Go decoder at At this time, I don't expect to have the time to work on this soon. |
Ideally one would use Zopfli (or another gzip-compatible algorithm) to generate gzip-compatible data and Brotli to generate brotli. Overall output size will always be less than factor 2, I estimate maybe factor 1.6 when storing both encodings. Having both encodings available would be ideal because the raw bytes could be directly used for HTTP-based transfer compression. I agree it needs to be configurable (allow 0, 1 or 2 algorithms) and the raw bytes need to be accessible for all algorithms too. |
The compress maybe as an interface so that external could implement themselves. |
96.6% of browsers today support brotli, so I'm of the opinion now that gzip is no longer needed for frontend asset delivery, and the primary compression method should be brotli. Any client in those 3.4% not supporting brotli that can just get uncompressed stream. |
Hi,
Brotli is a new compression method that produces smaller files than gzip. It's well supported by browsers.
It should be possible to compress the webroot directory with both gzip and brotli; store both versions in the generated
assets.go
file; and serve the best version of the file ifbr
is in theAccept-Encoding
header.The main C brotli encoder/decoder has a CGO wrapper here: https://github.com/google/brotli/tree/master/go
There is also a pure-Go version of the brotli encoder/decoder here https://github.com/andybalholm/brotli converted with c2go (read more)
Thanks
The text was updated successfully, but these errors were encountered: