Setting up Brotli on Nginx

Brotli is a relatively new compression algorithm that was developed by Google in order to help further reduce the size of files. This means less bandwidth is used to transfer files that take advantage of Brotli compression and visitors accessing these files to receive them faster.
Setting up Brotli on Nginx
Thursday 03. January 2019 Posted in:

At the time of sharing this video, we, at JaD are auditing our website to improve the speed and quality of our web services and content to our valued users. Brotli was one of the tools that were recommended to us by Google Lighthouse auditing tool. Individualistically, We've used Brotli in the past on various projects. Now, thanks to the experiences of our team members, we were able to install Brotli quite easily, of course with the help of this video. Setting up Brotli on Ngnix, Apache2 and other major servers are quite effortlessly easy and terse. It took us less than 5 minutes to install and setup.

Brotli in action

After setting up Brotli, we saw a 12% increase in performance. Pages were loading faster and more reliable. 

  • Javascript files compressed with Brotli are at least 23% smaller than gzip
  • CSS files are 13% smaller than gzip. We haven't minified our CSS and JavaScript files as yet. CSS/JS minification is our next agenda.

Just like gzip, Brotli is also a compression algorithm. It is developed by Google and serves best for text compression.

Installation Steps

sudo apt-add-repository -y ppa:hda-me/nginx-stable
sudo apt-get update -y
sudo apt-get install brotli nginx nginx-module-brotli

Test if Nginx is configured properly by using

nginx -V 2>&1 | tr ' ' '\n' | grep brotli

Restarting Nginx

sudo service nginx restart

Configuration

brotli on;
brotli_comp_level 6;
brotli_static on;
brotli_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/vnd.microsoft.icon image/bmp image/svg+xml;

Menu
×