go-siris / siris

DEPRECATED: The community driven fork of Iris. The fastest web framework for Golang!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

brotli compression

godofdream opened this issue · comments

Many modern Browsers support brotli compression.
We should add optional brotli compression. It does not need to be best compressionlevel.

https://caniuse.com/#search=brotli

Some information for this:
https://github.com/kothar/brotli-go (looks like it can used with streams as we need...)

I have create a feature/brotli-compression branch, for those that would like implementation it. Please use this repo to push and/or create PRs

I start to integrate brotli from https://github.com/google/brotli/tree/master/go/cbrotli
maybe it works as i hope :)

any idea how to make it working without compile brotli as lib before?
Can we deliver precompiled pkg's?

caddy has the same issue:
caddyserver/caddy#525

okay, so we need to support brotli precompiled files or the users need to compile that them self.

Wouldn't it be best to set the compression rate to the highest? Since the power of Brotli it's static system over Gzip's dynamic system. If a file get's compressed and never changes again it probably won't get a recompression. Brotli is much slower than Gzip, but if you Google the benchmarks you can easily get 15~25% more compression than on Gzip.

It kind of reminds me of doing this with Apache years ago under PHP, where you would pre-compress your assets with Grunt on Gzip level 9 and then purely serve the files compressed with the correct headers.

For static files you are right, the best compression will be the best, but for dynamic contents it would be the best to use quality 0 to 5. speed vs compression.

Maybe we should also try to implement for static files check for gzip an br accept header and check files with gz or br suffix.