mganss / ZopfliDll

Zopfli for IIS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ZopfliDll

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.

Usage (Zopfli)

  1. Copy the ZopfliDll.dll (or ZopfliDll64.dll) file to a folder accessible by the IIS process.

  2. Edit the <scheme> element of the <httpCompression> element in applicationHost.config (unfortunately, these settings cannot be overriden in Web.config):

    <httpCompression>
       <scheme name="gzip" dll="Path\To\ZopfliDll64.dll" />
    </httpCompression>
  3. 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 configCompression level used
IIS builtin
00
12
24
36
48
510
Zopfli (iterations)
61
75
810
915
1020

Usage (command line tool)

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).

Status

"Works on my machine"™ 😸

About

Zopfli for IIS

License:Apache License 2.0


Languages

Language:C 88.2%Language:C++ 11.4%Language:Objective-C 0.5%