I\'m trying to get the new Brotli compression scheme working in IIS using "Brotli compression module for Microsoft IIS" by iisspeed.com.
The Brotli compression
It appears the Brotli module you referenced requires a paid license, so I haven't tried it, but I encountered a similar issue with my own open source Brotli plugin for IIS.
As you pointed out, current browsers advertise Brotli support after gzip
and deflate
in the Accept-Encoding
header.
The HTTP RFC gives no specific guidance on how to choose from many Accept-Encoding
values with the same priority, so it would be acceptable to return br
content to those clients. However, it appears IIS always chooses the first one (left to right) that matches one of its configured compression schemes.
If you wish to leave both schemes enabled, you can modify the Accept-Encoding
header value on requests as they enter your IIS pipeline. The IIS URL Rewrite Module can do this with a simple rule.
The Accept-Encoding
header is represented by the HTTP_ACCEPT_ENCODING
Server Variable in the IIS pipeline, and you can modify it before it reaches the Compression Module(s). Here is a sample configuration:
The rule above looks for the string br
(surrounded by word boundaries -- and not immediately followed by ;q=0
) in the Accept-Encoding
header and re-writes it to be just plain br
, giving IIS only one choice.
Note that the default URL Rewrite configuration does not allow modification of the HTTP_ACCEPT_ENCODING
variable. The allowedServerVariables
element overrides that restriction and must be configured in applicationHost.config
. The rewrite rule can then be defined at any level in the config hierarchy, although it probably makes sense to make it global.