What you need
IIS compression is pluggable: the static and dynamic compression modules call a scheme provider DLL for each encoding. The built-in provider, %windir%\system32\inetsrv\gzip.dll, implements gzip and deflate only. Brotli comes from IIS Compression, a free Microsoft download that contains two providers:
iisbrotli.dll— a Brotli (br) scheme provider.iiszlib.dll— a zlib-based gzip/deflate provider that can replace the built-ingzip.dll.
Both are installed under %ProgramFiles%\IIS\IIS Compression\. They do not replace the IIS compression modules; you still need the Static and/or Dynamic Content Compression features installed (see installing IIS compression).
Step 1: install IIS Compression
Download the installer from the IIS Compression page on iis.net (https://www.iis.net/downloads/microsoft/iis-compression), choosing the 64-bit package for a 64-bit server, and run it as an administrator. A silent install works the same way as any MSI:
msiexec /i iiscompression_amd64.msi /quiet /norestart
iisreset
The installer registers the new providers in applicationHost.config. Always check the result rather than assuming it, as described in step 2.
Step 2: check the scheme configuration
Open %windir%\system32\inetsrv\config\applicationHost.config (or use the Configuration Editor in IIS Manager on system.webServer/httpCompression) and look for the scheme elements. A working setup looks like this:
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="br" dll="%ProgramFiles%\IIS\IIS Compression\iisbrotli.dll"
dynamicCompressionLevel="5" staticCompressionLevel="11" />
<scheme name="gzip" dll="%ProgramFiles%\IIS\IIS Compression\iiszlib.dll"
dynamicCompressionLevel="4" staticCompressionLevel="9" />
<!-- staticTypes / dynamicTypes as before -->
</httpCompression>
- Put
brfirst. When a client accepts several schemes equally, the order of theschemeelements decides which one IIS uses. Listinggzipfirst means browsers keep getting gzip even though Brotli is installed. - Levels. Brotli levels run from 0 to 11. Level 11 is fine for static files, which IIS compresses once and caches. For dynamic responses, which are compressed on every request, stay around 4–6; higher levels cost a lot of CPU for little gain.
- If you prefer to keep Microsoft's original gzip provider, leave the
gzipscheme pointing at%windir%\system32\inetsrv\gzip.dll; Brotli works either way.
You can also add the scheme from the command line:
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/httpCompression /+"[name='br',dll='%ProgramFiles%\IIS\IIS Compression\iisbrotli.dll',dynamicCompressionLevel='5',staticCompressionLevel='11']" /commit:apphost
Step 3: verify
curl -s -o /dev/null -D - -H "Accept-Encoding: br, gzip" https://example.com/ | findstr /i "content-encoding"
# content-encoding: br
Test over HTTPS. Browsers only advertise br on secure connections, so a site served over plain HTTP will keep receiving gzip from browsers even when IIS is configured correctly. Remember also that IIS compresses a static file only after it has been requested more than once in a short period (the frequentHitThreshold setting), so repeat the request before concluding that Brotli is not working.
Do not fake Brotli with URL Rewrite
Some older tutorials suggest an outbound URL Rewrite rule that sets the Content-Encoding response header to br whenever {HTTP_ACCEPT_ENCODING} contains br. That rule only changes the label, not the bytes. Clients then try to Brotli-decode a gzip or uncompressed body and fail with errors such as ERR_CONTENT_DECODING_FAILED or "truncated brotli stream". If you have such a rule, remove it; the scheme provider sets the correct header itself. The same goes for adding Vary: Accept-Encoding as a custom header: IIS adds it to compressed responses already, and a second copy is redundant. See content decoding errors for how to recognise the symptoms.
Azure App Service and ASP.NET Core
On Azure App Service you cannot run an MSI on the underlying IIS instance. Options for Brotli there are:
- A site extension. Community-maintained App Service site extensions exist that register the IIS Compression providers for your app (Windows plans only). They work, but you depend on a third party keeping the extension current, so review its source and update history before relying on it.
- ASP.NET Core response compression. The built-in Response Compression middleware (
AddResponseCompressionwithBrotliCompressionProviderandGzipCompressionProvider) compresses in your application and works on any hosting plan, including Linux. Make sure IIS's own dynamic compression is off for those responses so nothing is compressed twice. - Compress at the edge. If the app sits behind Azure Front Door or another CDN, let the edge compress and keep the app simple; see CDN compression.
Pick one of these, not several: stacking app-level compression, a site extension and edge compression mostly adds CPU and complexity.
When Brotli is still missing
Content-Encodingis gzip: check scheme order and that the request is HTTPS.- No compression at all: check that the MIME type is in
staticTypes/dynamicTypesand that the compression features are installed and enabled (install guide). - Brotli disappears behind a proxy or WAF: some intermediaries rewrite
Accept-Encodingtogzipor stripbrbefore the request reaches IIS. Log the header IIS actually receives (theHTTP_ACCEPT_ENCODINGserver variable) to confirm.
Frequently asked questions
Does IIS support Brotli natively?
The built-in IIS compression provider handles gzip and deflate. Brotli is added with Microsoft's free IIS Compression download, which provides the iisbrotli.dll scheme provider.
Where is iisbrotli.dll installed?
In %ProgramFiles%\IIS\IIS Compression\, together with iiszlib.dll. The br scheme in applicationHost.config points to that path.
Why does IIS still send gzip after installing Brotli?
Usually because the gzip scheme is listed before br in httpCompression, or because the test was made over plain HTTP, where browsers do not advertise br.
What Brotli compression level should I use on IIS?
Level 11 for static content, which IIS compresses once and caches, and a moderate level of about 4 to 6 for dynamic responses, which are compressed on every request.
Do I need the IIS Compression site extension on Azure App Service?
Only if you want IIS itself to produce Brotli. ASP.NET Core's Response Compression middleware or compression at Azure Front Door or a CDN are alternatives that do not depend on a third-party extension.