14 C
Texas
angeloma
Senior Writer and partner

How to enable the Brotli compression on Apache and Debian 10

Hello, friends. On a website, the speed and size of the files are vital to avoid possible crashes on the server. So today in this post, you will learn how to enable Brotli compression on Apache on Debian 10. It’s a simple process but it can help a lot.

Why do it?

The algorithm that Brotli uses is more efficient at compressing files than other compression methods. Therefore we will be able to notice how the files on our server will weigh less and this will influence the load of the files.

In general, you can expect files to be 15% to 25% smaller. So it is always a good idea to do it even if GZIP is the most popular among them. For a while, Brotli lacked the browser support that would allow it to be used in the same way as GZIP, but that changed and nowadays they are all supported.

So, in this post, you will learn how to enable it in Apache using Debian 10 as an example.

Enabling Brotli compression on Apache

- Advertisement -

One of the first things we have to do is to access the server or open a terminal.

Then proceed to update the whole system.

sudo apt update
sudo apt upgrade

Fortunately, Brotli is available from the official Debian repositories so installation becomes quite easy.

So to install it, run the following command:

sudo apt install brotli

This way, we already have the program installed. Now we need to link it with Apache so that they can do the job together.

First, enable the module in Apache. We can do this because recent versions of Apache include this module. In case you have manually installed apache, you have to rebuild it together with the module.

sudo a2enmod brotli 

Now in the virtualhost of your site, you have to add the following lines for the site to be processed with brotli.

<IfModule mod_brotli.c>
    AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/javascript
</IfModule>

Save your changes and close your editor,

And to apply the changes, you have to completely restart Apache.

sudo systemctl restart apache2

This is enough, but if you want to verify the process, you have to run the following command:

curl -I -H 'Accept-Encoding: br' [your-domain]

If on the output screen the value of Content-Encoding is similar to Content-Encoding: br, then the whole process has been successful.

Conclusion

In a web server, web server enhancement tools are essential for everything to work. The compression Brotli helps a lot in this task and with Apache, it can be useful.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article