go-siris / siris

DEPRECATED: The community driven fork of Iris. The fastest web framework for Golang!
Other
142 stars 16 forks source link

brotli compression #2

Open godofdream opened 7 years ago

godofdream commented 7 years ago

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

Dexus commented 7 years ago

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

Dexus commented 7 years ago

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

Dexus commented 7 years ago

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

Dexus commented 7 years ago

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

godofdream commented 7 years ago

caddy has the same issue: https://github.com/mholt/caddy/issues/525

Dexus commented 7 years ago

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

Allendar commented 7 years ago

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.

Dexus commented 7 years ago

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.