Content compression detection is faulty when brotli is enabled
-
Right now, when displaying the “gzip status” of a site, content compression is detected by making 3 HTTP requests to the site with certain headers to simulate a web request.
One issue with this is that the headers are not specific about what kind of compression is desired, and this results in a faulty status when
brotli
compression is enabled.brotli
is considered to be superior togzip
and so whenever a webserver has it available and the client supports it, it will normally be used. The result of this is your outbound web request, which looks a bit like this when rewritten in curl:curl --compressed -sIL -X GET "https://<home-url>/?avoid-minify=true"
Ends up returning
content-encoding: br
, which fails your checks and incorrectly warns the user that compression isn’t working properly.What you should really do to fix this is to change this:
$headers = array( 'Content-Type' => 'text/plain', );
To this, indicating you only accept
gzip
:$headers = array( 'Content-Type' => 'text/plain', 'Accept-Encoding' => 'gzip', );
Or alternatively, modify your checks to also accept
br
as a valid value for thecontent-encoding
header.
- The topic ‘Content compression detection is faulty when brotli is enabled’ is closed to new replies.