Rewrite rule ignored by webpagetest?

In our Windows Server 2019 IIS 10 site’s web.config using HTTP/2 protocol we have a rewrite rule:

<rule name="Prioritize Brotli" enabled="true">
	<match url=".*" />
	<conditions>
		<add input="{HTTP_ACCEPT_ENCODING}" pattern="\bbr(?!;q=0)\b" />
	</conditions>
	<serverVariables>
		<set name="HTTP_ACCEPT_ENCODING" value="br" />
	</serverVariables>
</rule>

And yet the Request for many objects still shows this, for example:

origin: https://my.domain.com
:path: /cms/content/fonts/Montserrat/Montserrat-ExtraBold.otf
accept-language: en-US,en;q=0.9
accept-encoding: gzip, deflate, br
sec-fetch-site: same-origin
accept: */*
user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36 PTST/210106.200150
:scheme: https
referer: https://my.domain.com/content/css/dark.min.css
sec-fetch-mode: cors
:method: GET
:authority: my.domain.com
sec-fetch-dest: font

What gives? I understood the rewrite rule will change the incoming accepted encoding to just show “br”, isn’t that right?

I don’t usually work on IIS machines and there were too many unknowns for me to narrow down the issue very much but some quick research combined with my experience with Linux servers led me to find these points to research further:

  • IIS 10 has differences between 2 different versions and they handle compression settings differently (and the ordering of configuration directives matters).

  • IIS won’t compress assets if it is computationally too expensive (an article suggested it would need to be using less than 80% CPU to honor compression requests).

  • Using and compressing fonts have lots of weird quirks like: (on Linux servers) the files themselves have to be set to ‘executable’; only some font formats can be compressed; Open TrueType fonts seem to have 2 different MIME types (font/otf and application/x-font-otf) so double check that either/both is configured.

  • In Apache and Nginx, an admin typically has to restart or reload the server before configuration changes take effect, does IIS have the same requirement and if so, did you do so?

Accept-encoding will be the compression methods that the user’s browser can use. Is the response content-encoding from the server showing as br?

Chrome should use br if it’s available. You’ll want to keep the other methods in place as fallbacks for other browsers that only except other methods.