Brotli compression improves website performance by offering approximately 20% better compression than existing algorithms such as GZIP.
Brotli is a generic-purpose lossless compression algorithm that compresses data using a combination of a modern variant of the LZ77 algorithm, Huffman coding and 2nd order context modeling, with a compression ratio comparable to the best currently available general-purpose compression methods. It is similar in speed with deflate but offers more dense compression.
When brotli is enabled, it takes precendence over gzip if Accept-Encoding has both gzip and brotli.
Nginx source tarball:
# wget http://nginx.org/download/nginx-1.10.3.tar.gz # tar -xzvf nginx-1.10.3.tar.gz
Brotli git clone:
# cd /usr/local/src # git clone https://github.com/google/ngx_brotli.git # cd ngx_brotli # git submodule update --init --recursive
Nginx reverse proxy build:
# ./configure --http-client-body-temp-path=/usr/local/src/nginx-1.10.3/tmp/body \ --http-fastcgi-temp-path=/usr/local/src/nginx-1.10.3/tmp/fastcgi \ --http-proxy-temp-path=/usr/local/src/nginx-1.10.3/tmp/proxy \ --lock-path=/var/lock/subsys/nginx \ --pid-path=/var/run/nginx.pid \ --user=nginx --group=nginx \ --without-mail_pop3_module --without-mail_smtp_module \ --without-mail_imap_module --without-http_uwsgi_module \ --without-http_scgi_module \ --add-module=/usr/local/src/ngx_brotli --prefix=/usr/local/src/nginx-1.10.3
Nginx reverse proxy configuration:
http { … brotli on; # brotli_static on; brotli_comp_level 4; # brotli_types *; … }
YMMV …
Source: https://github.com/google/ngx_brotli
Source: https://www.enovate.co.uk/blog/2017/02/28/how-to-brotli-compression-with-nginx
Source: https://www.enovate.co.uk/blog/2017/02/27/brotli-compression
Source: https://www.voorhoede.nl/en/blog/static-site-implosion-with-brotli-and-gzip/
Source: https://blogs.akamai.com/2016/02/understanding-brotlis-potential.html