Brotli, Gzip correct order

Zoltan Szabo

Active Member
Jul 13, 2017
41
7
8
Hungary
cPanel Access Level
Root Administrator
Dear All,

In a nutshell:
How to set apache to favour Brotli over Gzip if both available!

Story + Troubleshooting:
Today I have enabled brotli via WHM => EasyApache => Apache modules => mod_brotli
Online test show status okay: Brotli Test | Brotli compression check

So far so good, but in chrome 72 dev tools I still see "content-encoding: gzip"
The Chrome default request header is: "accept-encoding: gzip, deflate, br"

I have changed the request header with a "ModHeader" named chrome extension.
If its set to "br" it serves well with brotli if its gzip it server with "gzip".
Here I tried to change the request header order to "accept-encoding: br, gzip"
And its still GZIP <= Here is the problem

I can clearly state that with the default apache Gzip (optimise website) and mod_brotli together prefers Gzip over Brotli which is a false logic, I want it on the other way!

Can anyone help me how to configure apache to favour Brotli over Gzip if both available.
 

Zoltan Szabo

Active Member
Jul 13, 2017
41
7
8
Hungary
cPanel Access Level
Root Administrator
Just to avoid any confusion here, my application doesn't pre compress any source. (None)
So its not the case that Brotli avoides double compression coused by gzip pre compression.

But I do beleive double compression avoidance could still be a problem. e.g. Gzil/deflate runs first then Brotli doesn't as it avoides double compression, so it just stays Gzip. (I might be wrong with this assumption - please correct me)

Any idea how to solve this ?
 

Zoltan Szabo

Active Member
Jul 13, 2017
41
7
8
Hungary
cPanel Access Level
Root Administrator
Hello @Zoltan Szabo,

Can you open a support ticket so we can take a closer look at this issue? You can post the ticket number here and we'll link this thread to it.

Thank you.
Dear @cPanelMichael ,

Before opening a support ticket I tried to troubleshoot it myself. I think I have a solution and also found a bug.

I think the problem is with the inclusion order of the WHM brotli config file and the Cpanel optimise config file.
See article here: Setting up Brotli Compression on your WebServer
"Note that you need to specify the Brotli config first, or Apache will use gzip in preference to Brotli."

Means Brotli needs to be first than Gzip/Deflate

Temporaly solution:
1. Keep mod_brotli installed (in WHM)
2. Disable Optimise website (In Cpanel)
3. Add Gzip / Deflate to each of the running websites .htaccess which is loaded long after Brotli init.

This way it works very well, but this is still a kind of bug in Cpanel, by time you need to include Gzip or Brotli or both option in optimize website! Please upvote it here: Configure Brotli per-account

I also discovered that webmanifest file zipping is somehow missing from default Gzip and also Brotli config file
(application/manifest+json) MIME also needs to be added otherwise webmanifest not zipped!

@cPanelMichael can you let me know where can I report this bug?

Bye,
Zoli
 
Last edited:

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,910
2,233
363
cPanel Access Level
DataCenter Provider
Twitter
Hello @Zoltan Szabo,

Our defect report form is available on the link below:

cPanel Customer Portal

Let me know the ticket number assigned to the report once it's opened and I'll update this thread with the outcome.

Thank you.

Update: Here's a quote from the support ticket explaining the outcome:

I reviewed our internal documentation and determined that enabling brotli compression as a global default configuration was a decision that was intentionally made by our developers. Therefore in this case this behavior does not warrant a bug report, as it is an intended feature.
Thank you.
 
Last edited: