1

I installed and enabled the Brotli module just fine through SSH. Then, I added this to my port 80 VirtualHost config:

<IfModule mod_brotli.c>
    SetOutputFilter BROTLI_COMPRESS
    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-brotli
    AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/javascript
</IfModule>

After restarting Apache, everything is still served via gzip and not Brotli. Specifically, I see content-encoding: gzip for each text-based file, not content-encoding: br as expected.

Edit: my headers include accept-encoding: gzip, deflate, br so that can't be the problem.

Every tutorial that I've researched has very simple instructions yet gzip insists on being the preferred compression method no matter what I try. Going over the VirtualHost config files, I can't see anything about gzip or compression in them at all so it's odd that adding the above to those config files has no impact at all.

  • 1) What is the result from this test: `curl -I -H 'Accept-Encoding: br' URL`? If you see `Content-Encoding: br` then Brotli compression is working. 2) If not, you have a configuration problem. 3) Your request specifies three compression methods. The server has picked one. 4) Try moving `br` to the front of your `accept-encoding` header. 5) Try adding the qualifier `Accept-Encoding: gzip;q=0.5, br;q=1.0` to the request to specify compression preference. Update your question with more details from my comments. – John Hanley Oct 06 '22 at 02:25
  • @John I can test the curl command tomorrow. For now, 3/4/5 - it is `accept-encoding: gzip, deflate, br` because that's what's default in Chrome. Does that mean Chrome prefers gzip over Brotli? ie: if a site can serve both, does Chrome decide to request gzip? – JimmyTheCuck Oct 06 '22 at 02:42
  • Yes, the `accept-encoding` header specifies client preference left to right unless a qualifier is added. That means if both the server and client support `gzip` and `gzip` is first, `gzip` will be selected usually. There are other headers that can affect that decision. – John Hanley Oct 06 '22 at 03:12

0 Answers0