What is Brotli Compression? Why Brotli is better than Gzip?

What is Brotli Compression? Why Brotli is better than Gzip?

Brotli is a type of compression developed by Jyrki Alakuijala and Zoltán Szabadka. It is an Open Source technique and based on the modern LZ77 algorithm, 2nd order and Huffman coding context modeling. This will boost the website performance much more in all browsers. Brotli was released on 2015 September by Google software engineers by enhancing lossless data compression with the use of HTTP compression.

The Brotli compression technique uses a pre-defined 120Kb dictionary in addition with Sliding Window dictionary. Brotli compression ensures better space utilization and faster page loads with smaller compressed size and it is far better than gzip compression mechanism.  While Gzip compression uses a fixed window of 32KB but in Brotli uses a sliding window of 1KB to 16MB. Let’s discuss some of the benefits of Brotli compression technique:

1) A quicker website access

2) Improved security

3) Increased trust from Google leading to improved rankings.

Unlike Zopfli compression which is Deflate-compatible, Brotli compression is a new type of data format which offers significant compression which will attain 20-26% better than Zopfli compression. Apache now adds support to 2.4 version, but it does require Brotli library and some compile options. Let’s discuss about the steps to set up Brotli compression in Apache 2.4:

1) Make sure you have already installed “wget, perl, gcc, pcre-devel, cmake.x86_64” packages. And then execute below commands to enable Brotli compression on Apache webserver.

# cd ~

# mkdir sources && cd sources

# git clone https://github.com/google/brotli.git

# cd brotli/

# git checkout v0.6

# mkdir out && cd out

# ./configure-cmake

# make

# make test

# make install

2) Now we need to install Latest version Apache 2.4.26 or higher. You can easily install by executing below commands.

# wget https://www.apache.org/dist/httpd/httpd-2.4.26.tar.gz.asc

# tar -zxvf httpd-2.4.26.tar.gz

# cd httpd-2.4.26

# ./configure –with-pcre=/usr/bin/pcre-config –enable-ssl –enable-so –enable-brotli –with-brotli=/usr/local/brotli

# make

# make install

3) Next, we need to enable the compression on Apache configuration file. This is similar to Gzip compression configuration. Add below codes to “brotli.conf” file and Include the location at Apache configuration file.

LoadModule brotli_module modules/mod_brotli.so

<IfModule mod_brotli.c>

AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript application/json application/x-font-ttf application/vnd.ms-fontobject image/x-icon

BrotliFilterNote Input brotli_input_info

BrotliFilterNote Output brotli_output_info

BrotliFilterNote Ratio brotli_ratio_info

LogFormat ‘”%r” %{brotli_output_info}n/%{brotli_input_info}n (%{brotli_ratio_info}n%%)’ brotli

CustomLog “|${APACHE_ROOT}/bin/rotatelogs ${APACHE_LOG_DIR}/brotli_log.%Y%m%d 86400” brotli


#Don’t compress content which is already compressed

SetEnvIfNoCase Request_URI \

\.(gif|jpe?g|png|swf|woff|woff2) no-brotli dont-vary


# Make sure proxies don’t deliver the wrong content

Header append Vary User-Agent env=!dont-vary


Then restart Apache service and you can see the Content-Encoding as “br” on your browser text resources.


If you need any further help, please reach our support department.

  • 0

Install Wine on Linux Distribution

Install Wine on Linux Distribution In this tutorial, we can check how to Install Wine on Linux...

Install Apache Tomcat on Ubuntu 18.04

Install Apache Tomcat on Ubuntu 18.04 The Apache Tomcat is a free, open-source Java-based web...

How to Install and Setup Angular CLI

How to Install and Setup Angular CLIAngular is an open-source framework for your web...

How to Install Jenkins on CentOS and Ubuntu Server?

How to Install Jenkins on CentOS and Ubuntu Server? Jenkins is a free and open-source automation...

Setup ILIAS LMS on Ubuntu 18.04/16.04 with Nginx

ILIAS is an Open-Source Learning Management System. ILIAS LMS offers to develop and realizing...