As website owners strive to improve the speed and performance of their websites, Brotli compression has become increasingly popular for working towards these goals. Brotli is an open-source compression algorithm that was developed by Google and is designed to provide various benefits.
While Brotli has been available for several years, many website owners still struggle with how to implement it on their servers. In this article, we'll take a closer look at how to add Brotli compression to IIS, one of the most popular web servers in use today.
Install Brotli Compression Module for IIS
To get started with adding Brotli compression to your IIS server, the first step is to install the corresponding module. This can be downloaded from the official Microsoft website and installed on your server by downloading and running it.
Therefore you want to first stop the WAS and W3SVC services by running net stop was /y
. Then, execute the downloaded file by either executing msiexec /I iiscompression_x86.msi
or msiexec /I iiscompression_amd64.msi
, depending on the filename and OS architecture. After accepting the EULA and completing the installation, start the WAS and W3SVC services again (net start w3svc
.
Configure Brotli Compression in IIS
Configuration for Brotli in IIS is not as trivial as for Apache or NGINX. You want to add an httpCompression
section to your applicationHost.config
file, which should look similar to this:
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files"> <scheme name="br" dll="%ProgramFiles%\IIS\IIS Compression\iisbrotli.dll" /> <scheme name="gzip" dll="%ProgramFiles%\IIS\IIS Compression\iiszlib.dll" /> <dynamicTypes> <add mimeType="text/*" enabled="true" /> <add mimeType="message/*" enabled="true" /> <add mimeType="application/x-javascript" enabled="true" /> <add mimeType="application/javascript" enabled="true" /> <add mimeType="*/*" enabled="false" /> </dynamicTypes> <staticTypes> <add mimeType="text/*" enabled="true" /> <add mimeType="message/*" enabled="true" /> <add mimeType="application/javascript" enabled="true" /> <add mimeType="application/atom+xml" enabled="true" /> <add mimeType="application/xaml+xml" enabled="true" /> <add mimeType="image/svg+xml" enabled="true" /> <add mimeType="*/*" enabled="false" /> </staticTypes></httpCompression>
This configuration enables Brotli compression for all static and dynamic content that is text-based. You can also enable Brotli compression for specific file types only, by adding the corresponding file types to the staticTypes
and dynamicTypes
sections.
Test Brotli Compression
Once your IIS is ready serving Brotli-compressed content, you should test if the Brotli compression is working correctly. You can use our Brotli checker to check your website and see if it worked.