Enabling HTTP Compression
Suitable File Types
Enabling HTTP Compression
– IIS 6
– IIS 5 and Earlier
Effects on Server Performance
HTTP Compression is a function of the server, but the browser automatically supports it without any additional configuration on the client. To start gaining the benefits of compressed content, simply enable compression on the server.
The way to do this differs among Apache, IIS6, and previous version of IIS.
Apache 2.0 comes with the mod_deflate, which adds a filter to Gzip the content (don’t let the term “deflate” fool you, though) content. Filters can be blanket — in Internet Explorer everything is compressed — or selective — compressing only specific MIME types (determined by examining the header generated, either automatically by Apache or a CGI or other dynamic component.
To enable blanket compression, set the SetOutputFilter directive to a Web site or Directory container, for example:
To enable compression on specific MIME types, use the AddOutputFilterByType directive, for example:
AddOutputFilterByType DEFLATE text/html
Note that this compresses all output with this MIME type, so if the CGI code or other applications (e.g., Tomcat or mod_perl) are generating the right HTTP content header as part of their operation, the output will be compressed as well.
Some browsers, particularly older ones, may not work correctly with compressed formats. Compression filtering for specific browsers is disabled using the BrowserMatch directive. Check out the mod_deflate documentation for more information.
IIS 6 includes a native compression system that is easy to use and deploy. Because it’s built-in, rather than operated by an ISAPI filter, it is very fast and has basically put the previous commercial alternatives available for IIS 5 and earlier out of business. The compression system can be configured to compress both static content and dynamic content (i.e., scripted output). IIS 6 also caches the compressed information in a directory, which helps improve the performance for both static and script-based responses by eliminating the need to compress already compressed content.
To enable HTTP compression in IIS 6, open the Web site’s property page to edit the global properties for the site. Change to the Service tab, and configure the options within the HTTP Compression section.
Figure 1 is a sample of a window.
Setting HTTP Compression in IIS 6
Cached files are stored in the Temporary Directory. The default is within a suitably named directory within the IIS metadata directory. The directory selected must be on an NTFS partition. You can limit the size of the cache or leave it unlimited; we recommend setting a limit of about two-times the maximum size of the site (including the data it might generate from a scripted page).
There is no built-in compression for IIS versions prior to version 6, but ISAPI filters are available. All of these are understandably slower than the built-in facility in IIS 6. We recommend using the commercial ISAPI filter ZipEnable from Port80 Software.
Others are available, but ZipEnable is one of the few packages Microsoft specifically recommends. It is also compatible with IIS 6 and can further control the compression on a directory-by-directory level by editing the IIS 6 metabase configuration for you.