brancusi has asked for the wisdom of the Perl Monks concerning the following question:

O wise ones, please can you assist in a most vexatious problem I'm having with IIS6.

I am running a site under IIS6 on windows server 2003 using Activestate Perl as an ISAPI filter for cgi.

Everything works fine. Well as fine as anything can do under IIS ;-)

I want to enable gzip compression by the server of cgi content and have religiously followed the instructions provided both on the microsoft site here;

http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/25d2170b-09c0-45fd-8da4-898cf9a7d568.mspx?mfr=true
And checked it against some real world use here;
http://www.codinghorror.com/blog/archives/000059.html

All my STATIC content (eg html) is being compressed nicely thank you IIS. But NONE of my cgi content is being compressed :(

Here is the response to a request of a static file as shown by live http headers in firefox;

GET /terms.htm HTTP/1.1 Host: www.backupsdb.com:8000 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.1.2 +) Gecko/20090729 Firefox/3.5.2 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0. +8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive If-Modified-Since: Sat, 04 Jul 2009 10:57:03 GMT If-None-Match: "80a9992996fcc91:f46" Cache-Control: max-age=0 HTTP/1.x 200 OK Content-Length: 5527 Content-Type: text/html Content-Encoding: gzip Last-Modified: Sat, 04 Jul 2009 10:57:03 GMT Accept-Ranges: bytes Etag: "80a9992996fcc91:f42" Vary: Accept-Encoding Server: Microsoft-IIS/6.0 Date: Wed, 05 Aug 2009 10:12:34 GMT Connection: close

Here is the request and response to the SAME content, but being delivered by a cgi script.

GET /testzip.cgi HTTP/1.1 Host: www.backupsdb.com:8000 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.1.2 +) Gecko/20090729 Firefox/3.5.2 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0. +8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive HTTP/1.x 200 OK Expires: Wed, 05 Aug 2009 10:10:57 GMT Date: Wed, 05 Aug 2009 10:10:57 GMT Content-Length: 22527 Content-Type: text/html; charset=ISO-8859-1

This is the code fragment I am using in this test case for outputting the page of text;

my $length = length($HTML); print $cgi->header( -nph=>1, -Content_length=>$length, -expires=>'+0s', -type=>"text/html") ; print $HTML;

I've tried several variations such as turning off non parsed headers, adding a vary=>accept encoding header, but to no avail. I have a hunch that the ISAPI plugin is interfering with the IIS config for dynamic script compression but I could equally be doing something wrong ...

Has anyone here persuaded IIS6 to serve cgi content using the ISAPI perl filter OK?? If so, what's the secret please!!

Kind Regards
Roger

UPDATED -------

It seems that if instead of running Perl as an ISAPI filter, I run it as standard CGI, everything works as expected (implying my server config is probably ok) - except of course my performance is now hammered by the lack of persistence. Is this a bug in the implementation of the Perl ISAPI filter or is there a workaround??

Replies are listed 'Best First'.
Re: Persuading IIS6 to gzip Perl ISAPI cgi?
by merlponk (Scribe) on Aug 05, 2009 at 13:43 UTC
    I'm sorry, no clue as to how it works in IIS. But with Apache (mod_deflate), you have to specify which file types should be compressed. Maybe there's a setting for this in IIS, so that it not only compresses .htm and the like, but .cgi as well?