IIS Compression Overview
By Yanbing Shi
This article provides an overview of IIS Compression.
What is IIS Compression
IIS Compression is a bundle of two IIS compression scheme providers, iisbrotli.dll and iiszlib.dll, that expand IIS's capability to compress HTTP responses. iisbrotli.dll supports Brotli compression, while iiszlib.dll supports both Gzip and Deflate compression.
What is a compression scheme provider
An IIS compression scheme provider:
- Is a pluggable extension of IIS
StaticCompressionModule
andDynamicCompressionModule
. - Provides an implementation for one or multiple HTTP compression schemes.
IIS StaticCompressionModule
and DynamicCompressionModule
:
- Load the registered compression scheme providers into worker processes at runtime.
- Leverage them to perform compression on static files and dynamically generated content, respectively.
Why use IIS Compression
IIS ships a default compression scheme provider gzip.dll:
- That supports both Gzip and Deflate compression.
- Is registered as the gzip scheme in applicationHost.config by default.
The in-box gzip.dll is based on an internal implementation of Gzip and Deflate encoding, and it works properly. So why introduce new compression scheme providers in IIS Compression?
Higher Compression Ratio with Brotli compression
Brotli compression:
- Is a relatively new addition to the HTTP compression.
- Encoding algorithm and format of Brotli are specified in Requests For Comment (RFC) specification 7932.
- Response data streams compressed with Brotli have the content encoding type "br".
- Is capable of offering higher compression ratio than Gzip and Deflate, with the cost of lower compression speed.
Brotli decompression on the client (browser) side is in general faster. Enabling Brotli compression can potentially improve performance, especially for serving static contents.
Better Gzip Compression Scheme Provider
While iiszlib.dll included in IIS Compression offers same Gzip and Deflate compression as the default provider gzip.dll, iiszlib.dll:
- Is more up-to-date.
- Has better performance in terms of CPU usage.
- Has better dynamic compression support owing to the zlib library.
Open Source
IIS Compression
:
- Is a supported open-source product.
- Source code can be found in IIS.Compression Github repository.
- Uses the open-source brotli and zlib compression libraries as the core encoders
- Bridges the
brotli
andzlib
libraries with IIS compression modules through implementing the IIS HTTP Compression API.
Making IIS Compression
open-source provides transparency to the community and allows flexible and agile future enhancement, bug fixing, and customization. The project also serves a general reference for developing an IIS compression scheme provider to the community.
Installing IIS Compression
Before Installation
The iiszlib.dll and iisbrotli.dll compression scheme providers are not IIS modules, they are extensions of IIS StaticCompressionModule
and DynamicCompressionModule
. At runtime, StaticCompressionModule
and DynamicCompressionModule
load the compression scheme providers and pass the response content data to them for compression.
Therefore, one or both of the two compression modules need to be installed on the IIS server as a prerequisite. See HTTP Compression on how to install the features. Once the modules are installed, ensure static and/or dynamic compression are enabled for a desired URL namespace. See URL Compression on how to enable the corresponding type of compression.
Installation
Download the Microsoft IIS Compression release from the following locations:
Open a command prompt with administrator user rights.
Stop the WAS and W3SVC services by entering the following:
net stop was /y
Run iiscompression_<architecture>.exe; for example:
msiexec /I iiscompression_x86.msi
msiexec /I iiscompression_amd64.msi
Accept the End User License Agreement (EULA).
Complete the installation.
Start the WAS and W3SVC services by entering the following:
net start w3svc
The IIS Compression installer drops iisbrotli.dll and iiszlib.dll to %ProgramFiles%\IIS\IIS Compression
.
The installer registers iisbrotli.dll as the br (Brotli) compression scheme provider in applicationHost.config. It also replaces the default gzip compression scheme provider gzip.dll with iiszlib.dll. A sample <httpCompression>
element in applicationHost.config is shown below:
<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>