How to use brotli compression instead of gzip

SYSTEM INFORMATION
OS type and version Debian 11
Webmin version 2.105
Virtualmin version 7.9.0

I have been trying for the last 3 hours to activate brotli compression on https for some virtualhost.
1/ I did enable the brotli module in Webmin->Servers->Apache->Global Configuration->Apache modules, rebooted Apache.
2/ brotli seems to be enabled looking at phpinfo()
3/ then I added the following code to the virtualhost config both http/https:

<IfModule mod_brotli.c>
    AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript application/json application/xml
    BrotliCompressionQuality 4
</IfModule>

4/ rebooted Apache again

Of course I made many more tests and attempts, always rebooting Apache, I also tried to add

Header set Accept-Encoding br,gzip,deflate
Header set Content-Encoding br
Header set Vary Accept-Encoding

which broke Apache (the 2nd line in fact broke Apache), but whatever I change, when I look at http headers for my page I see:

content-encoding gzip
Accept-Encoding gzip, deflate, br

which is confirmed by tests at https://www.giftofspeed.com/
I read a lot, googled a lot, looked at almost each and every config files for Apache to no avail, even tried to suppress the deflate module (which I don’t seem to be able to do), I’m still on gzip, not brotli … what am I missing ?
Thanks for any tip that could put me on the right path …
Pierre.

They make it sound easy

I don’t think these doc are for rocky like OS as I don’t have the a2enmod command and apache2
I don’t have Webmin->Servers->Apache->Global Configuration->Apache modules that i can see.
It do have a config file

P.S. I added the code into one of the virtualservers and it worked (the site for testing you gave dosn’t work for me, found another and show great compression)

Improved page speed at https://pagespeed.web.dev

Hello,
That’s exactly the website I used to setup brotli, but still, tests on my website shows that I’m still using gzip.
I made some more tests with different testing sites and it seems that my server is properly setup for both, I found 2 or 3 testing sites that do test both methods and they are telling me brotli is available and functionning, but still, the default method still seems to be gzip. For example Brotli Test - Verify Brotli Compression Support | KeyCDN Tools states that “Brotli compression is supported.”.

I think it might be a consequence of:

Accept-Encoding gzip, deflate, br

Which shows gzip as being the first method used … and this is the real header as seen when doing a webpage inspection (network, headers), so as of now, I think I did setup brotli properly but I would have to amend that order to have brotli as the preferred method.
I looked everywhere in all the Apache config files, I cannot find that line anywhere … I would like to make it

Accept-Encoding br, gzip, deflate

That’s my current thinking at this time … well … I also tried adding

    Header add Accept-Encoding: br

to the virtual host config file, to the htaccess … the web inspector still gives me the same result, gzip is used.
Pierre.

remove gzip from that line, what happens?

Well of course that’s the main purpose of my question … finding that line !

But, in the mean time I did more tests and I was able to get it to work.
When looking at /etc/apache2/mods-available and /etc/apache2/mods-enabled I was seeing a brotli.load but no brotli.conf … I manually added brotli.conf with

<IfModule mod_brotli.c>
    AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript application/json application/xml
    BrotliCompressionQuality 4
</IfModule>

and it started to work right away ! I don’t know if this is the right way to do it, well the .load and .conf are ok, what I don’t know is the reason why I had to do this manually … I don’t recall having to do this for other Apache modules added through Virtualmin.
Pierre.

All I did was add here, Rocky9 had brotli already configured.