Enable Brotli on Apache!
Apache already comes with a Brotli module built-in (since version 2.4.26). In case you have a version lower than
that, please upgrade your Apache server! Also, in case you don't have HTTPS enabled on your server by now, you
should do it soon (read: now). Getting an HTTPS certificate with Let's Encrypt
is easy and free.
With HTTPS set up, you can now enable the apache module with
a2enmod brotli if it is not already
enabled out of the box. Now, open your VirtualHost or server config and add the output filter for Brotli:
(neither with GZIP nor Brotli) as they are already compressed!
If you want to change the compression level, use
BrotliCompressionQuality LEVEL. The default is
5 but we would suggest using 4 as it's both: faster and more efficient than GZIP.
Be aware that Apache does not support static compression (like you can achieve with webpack, express or other technologies). All compression is done on the fly while requesting the file