3 comments

[ 2.9 ms ] story [ 14.1 ms ] thread
Author here!

Brotli's awesome - it's the next best thing after HTTP/2 to add free speed to your site - but when researching this article (which we used for our own Brotli deployment at CertSimple) I found there's a lot of misleading stuff in many Brotli tutorials:

- 'Brotli is slow' is only true at maximum settings (11). 'Brotli is too slow for dynamic content' is definitely wrong. At setting 4, Brotli is faster AND compresses better than gzip.

- If nginx is not on the same server as your JS bundles - eg, you have an nginx load balancer using proxy_pass to send traffic to your app servers, and your app servers just run node/ruby/elixir/python etc, brotli_static won't help. Use a language-specific module - like Shrink-Ray for node - instead.

- If you do use nginx, 'brotli_types *;' is silly: Brotli is for JS, HTML, SVG, JSON and XML. JPEGs, PNGs, MP4s etc already have format-specific compression that's better than brotli and compressing these types just wastes CPU and might even end up making them bigger.

- If you do use nginx, you don't have to build Brotli from source, For Ubuntu 16.04:

    sudo apt-add-repository -y ppa:hda-me/nginx-stable
    sudo apt-get update
    sudo apt-get install brotli nginx nginx-module-brotli
Packages are provided by cryptofuture who's an excellent maintainer.

- Using nginx load balancer for brotli? Disable compression on your app servers - nginx won't recompress something if it's already compressed.

If HN folks can recommend good Ruby/Elixir/Python/Go/Rust Brotli modules I'll add them to the article too.