It looks like the Brotli module you are linking to requires a paid license, so I haven't tried it, but I ran into a similar problem with my own open source Brotli Plug-in for IIS .
As you pointed out, current browsers advertise Brotli support after gzip and deflate in the Accept-Encoding header.
The HTTP RFC does not provide specific guidance on how to choose Accept-Encoding from many values ββwith the same priority, so it would be acceptable to return br content to these clients. However, it seems that IIS always selects the first (from left to right) that matches one of the configured compression schemes.
If you want to leave both schemes enabled, you can change the Accept-Encoding header value for requests when they enter your IIS pipeline. The IIS URL rewriter can do this with a simple rule.
The Accept-Encoding header is represented by the HTTP_ACCEPT_ENCODING Server Variable variable in the IIS pipeline, and you can change it before it reaches the compression module (s). Here is an example configuration:
<rewrite> <allowedServerVariables> <add name="HTTP_ACCEPT_ENCODING" /> </allowedServerVariables> <rules> <rule name="Prioritize Brotli"> <match url=".*" /> <conditions> <add input="{HTTP_ACCEPT_ENCODING}" pattern="\bbr(?!;q=0)\b" /> </conditions> <serverVariables> <set name="HTTP_ACCEPT_ENCODING" value="br" /> </serverVariables> </rule> </rules> </rewrite>
In the above rule, the string br (surrounded by word boundaries, not immediately after it ;q=0 ) in the Accept-Encoding header and rewrites it as just br , giving IIS only one choice.
Note that setting the default Rewrite URL does not allow you to modify the HTTP_ACCEPT_ENCODING variable. The allowedServerVariables element overrides this restriction and must be configured in applicationHost.config . The rewrite rule can then be defined at any level in the configuration hierarchy, although it probably makes sense to make it global.
source share