ZopfliDll is a custom extension library for Microsoft IIS that can compress with Google's Zopfli algorithm or a configurable command line tool (such as 7-Zip). It can replace the builtin gzip compression library (gzip.dll).
If you want to try it out on the command line, check out this other project.
-
Copy the
ZopfliDll.dll
(orZopfliDll64.dll
) file to a folder accessible by the IIS process. -
Edit the
<scheme>
element of the<httpCompression>
element inapplicationHost.config
(unfortunately, these settings cannot be overriden in Web.config):<httpCompression> <scheme name="gzip" dll="Path\To\ZopfliDll64.dll" /> </httpCompression>
-
Restart the "World Wide Web Publishing Service".
Static files are by default saved to %SystemDrive%\inetpub\temp\IIS Temporary Compressed Files
.
Because you cannot have different DLLs for dynamic and static compression (and the DLL does not know whether it's compressing dynamic or static content), ZopfliDll uses the compression level to switch between the builtin fast gzip compression and the slow Zopfli algorithm:
Compression Level in IIS config | Compression level used |
---|---|
IIS builtin | |
0 | 0 |
1 | 2 |
2 | 4 |
3 | 6 |
4 | 8 |
5 | 10 |
Zopfli (iterations) | |
6 | 1 |
7 | 5 |
8 | 10 |
9 | 15 |
10 | 20 |
ZopfliDll has a second mode of operation which allows you to compress content using an arbitrary command line tool. If ZopfliDll finds a file called cmd.txt
in the same folder as the DLL, it uses the content of this file to start a command line tool for each stream of data to compress.
The command line tool should read uncompressed data from stdin and write compressed data in gzip format to stdout. The command line may contain environment variables and a placeholder for the compression level. Example:
%ProgramFiles%\7-Zip\7z.exe a dummy -tgzip -mx={1;9} -si -so
Compression levels of 0-5 in the IIS configuration are used for compression with the builtin gzip compression as in the table above. Levels 6-10 are spread to the range in the placeholder (1-9 in the example).
"Works on my machine"™ 😸