h5bp/server-configs-apache

Question: Why is the Brotli algorithm not added on this code line?

summercms opened this issue · 2 comments

Quick question, maybe it's me being stupid.

Why is the Brotli algorithm not added on this code line?

RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding

In my mind I keep thinking it should be this:

RequestHeader append Accept-Encoding "br,gzip,deflate" env=HAVE_Accept-Encoding

Note: I added br to the above code line.

I was thinking it should be mentioned to add it here as a choice between br and gzip.


The reason I ask is because my server is saying this (php level):

[HTTP_ACCEPT_ENCODING] => gzip

Yet the front-end is saying in the browser:

Accept-Encoding: gzip, deflate, br

I have this turned on: src/web_performance/pre-compressed_content_brotli.conf

I have this turned off: src/web_performance/pre-compressed_content_gzip.conf

I have this: src/web_performance/compression.conf

As this:

    <IfModule mod_setenvif.c>
        <IfModule mod_headers.c>
            SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
            RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
        </IfModule>
    </IfModule>

But I want to ask, should it not be this:

    <IfModule mod_setenvif.c>
        <IfModule mod_headers.c>
            SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
            RequestHeader append Accept-Encoding "br,gzip,deflate" env=HAVE_Accept-Encoding
        </IfModule>
    </IfModule>

Thanks in advance.

Thanks for opening this issue, @ayumi-cloud.

First of all, please keep in mind that Accept-Encoding is a request header, meaning that it comes from the client (which might not support br) not the server, meaning that Apache httpd config can't change the value.

Why is the Brotli algorithm not added on this code line?

As the description of this part explains, this is only to cover old and malformed Accept-Encoding header.
It is not recommended to override client header, especially in this case where you will override support compression list. You might send incompatible content.

# Force compression for mangled `Accept-Encoding` request headers

The reason I ask is because my server is saying this (php level):

As you explained, this is on PHP level, managed by your PHP process manager. This is nothing with Apache httpd.

Yet the front-end is saying in the browser

That's cool, you have a modern browser!

I have this turned on: src/web_performance/pre-compressed_content_brotli.conf

I hope you understood what it imply 🙂

But I want to ask, should it not be this:

What is the goal? Saying that the client support br when it's not? Again, not recommended.

@LeoColomb Thanks for the explanation, I get what you are saying and I understand now 👍