The Brotli compression is opted by the top tech fortunes like Cloudflare etc. This is the reason, we recommend switching to brotli from the old deflate data compression algorithm. This tutorial helps you to enable brotli compression in the Apache webserver.


Shell access to your server with sudo privileged account. We assume that you already have a running Apache server. Also created a virtual host for the web application.

Step 1 – Installing Brotli

First, install the brotli package on your system. For the Ubuntu and Debian systems, it’s available in the default repositories. Open a terminal and type: This will install the required package containing the algorithm files on your system.

Step 2 – Configure Brotli with Apache

The Apache server contains the Brotli module default. You can enable the brotli module in Apache with the following command. Next, you have to configure the Apache virtual host to enable compression with brotli. You need to add the below code in the virtual host configuration file.

After enabling the brotli compression the Virtual host configuration file looks like below:

Save the configuration file and close it. Then reload the Apache service to apply changes. That’s it. You have successfully enabled brotli compression in the Apache server.

Step 3 – Test Compression

Access your web application in a browser and check headers value in the browser console. You need to search for the Content-Encoding value. It must contain br as value, which denotes that the web page is compressed with brotli compression. The command line heroes can also use curl command to access the header values as below: You will see the result below. Check for the value of Content-Encoding option.


This tutorial helped you to configure Brotli compression in the Apache webserver.