FlatCompression ISAPI Filter
- Documentation -

 

Release Date By Comment
R1.01.147 2002-04-25 U.Margull First documentation of FlatCompression Filter
R1.10.171 2002-06-20 U.Margull Preparing the FlatCompression for Open Source

Content

Thanks to 1 mal 1 Software GmbH, Fürth, Germay, who developed and donated the original filter software. The filter was developed for the FLATCAST video/audio streaming portal.

Design and programming was done by Uli Margull, with thanks to Johannes Welck, Martin Miller and the 20kBit Michael!

Overview

The FlatCompression filter is used to compress the entity of the http response.

The compression itself is done with the zlib library (www.zlib.org).

Installation and Parameters

Installation

IMPORTANT: The ISAPI filter FlatComp.dll has to be installed as a IIS-wide ISAPI filter. This means, it can not used on a single virtual web presence, but only system-wide.

Parameters

For default mode, no registry settings are necessary. The filter should work out-of-the-box. In the default mode, all responses with Content-Type: text/html are compressed.

Some of the filter behaviour can be changed by registry settings. These settings are found unter HKLM->Software->FlatCompression. The settings are:

Name Type Default Description
Flags REG_DWORD 0 Special flags for filter behaviour. Right now the following bitmasks are defined:

Bit 0: If set: Log each compression

mime REG_MULTISZ text/ Mime types that will be compressed. All entries that match are compressed. The default value compresses all text/* mime types, e.g. text/html, text/plain, text/css, etc.

A maximum of 5 entries will be used by the filter.

The parameters are loaded when the filter starts (i.e. when IIS starts). A reload of the parameters can be forced by calling the following URL: /FlatCompression/InitFilter (case sensitive!). No http response is returned, the browser looks like hanged up afterwards.

FAQ

Here are some of the questions I have already answered:

Why is the compressed content not cached? That would save a lot of CPU power.

Yes, when compressing a static html page, one could cache the compressed response. The IIS5 does this, and it works pretty fine. If you need this feature, use the IIS5 compression filter (can be used additionally to the FlatCompression filter).

However, dynamic content cannot be cached since, well, its dynamic. The primary use of this filter is with dynamic content, and therefor no caching was implemented. Adding caching would involve be a complete redesign of the software, and at the moment, its not even on the to-do list. But this is open source, and if theres a demand, it will probably be done one day or another.

How do I install an ISAPI filter?

Well, if You dont know how to do this, better be careful and check the IIS manuals first.

Since the filter has to be installed as a system wide filter, heres a short description of how its done:

  1. Open the computer management console and switch to 'Services and Applications'
  2. Right-click on 'Internet Information Services' and select 'Properties'
  3. In the 'Internet Information Services' rider, select 'Master Properties: WWW Service' and press 'Edit'
  4. Select the 'ISAPI filters' rider, and press 'Add'
  5. In the field 'Filter Name', write 'FlatCompression'. The 'Browse' to the FlatCompression dll, or write the full path in the 'Executable' field, e.g. C:\FlatComp-1-10-171D.dll.
  6. Press ok, and the FlatCompression should appear in the list of filters.
  7. Close 'WWW Master Service Properties' by clicking on 'OK'.
  8. Close 'Internet Information Service Properties' by clicking on 'OK'.
  9. Right-click again on 'Internet Information Services', and select 'Restart' this time.
  10. Click 'OK' in order to restart internet information services.
  11. Thats it, the filter should be up and running. You can check this in the 'ISAPI filters' list (repeat steps 2, 3, 4).

How it works

The filter looks at the incoming request. If the Accept-Encoding header contains 'gzip' or 'deflate', then the compression is activated. When the response is prepared by the server, the filter looks at the response, especially at the Content-Type. If the mime type of the response should be compressed, then a special header Content-Encoding: is added. The entity of the response then is compressed and the compressed entity is sent to the browser.

How to calculate the content length of the response

When sending a response to the browser, the content length has to be known. This is not known at first. Therefor, the complete header and the complete answer is cached in the filter. When the complete answer is available, it is compressed, the compressed size is added to the header, and the header as well as the compressed entity are sent to the browser.

Todo list / to be expected soon

Release Notes

Release R1.10.171 of 2002-06-20

Release R1.01.147 of 2002-04-25