Gzip not working for javascript files only in IIS 7 integrated with Tomcat 7 using isapi_redirect.dll

246 Views Asked by At

I am using the tomcat connector (isapi_redirect.dll) to integrate with IIS 7.

After enabling both static & dynamic compression at website level using IIS Manager, the gzip compression is not working for only javascript files.

After little debugging, figured out that the Content-Type of .js request is also strangely not application/x-javascript as it should have been according to the mimeMapping applicationHost.config, instead it is application/javascript.

I've already tried adding mimeType application/javascript to applicationHost.config and also in web.config under httpCompression tag. But nothing worked.

Although enabling compression at Tomcat7 level works fine (accessing the site on port 8080).

I have also tried to use a different connector - http://tomcatiis.riaforge.org but the same issue - .js files doesn't compress.

Please help.

1

There are 1 best solutions below

0
coding_idiot On

Change the mimeType of js files in Tomcat7/conf/web.xml to application/javascript.

    <mime-mapping>
        <extension>js</extension>
        <mime-type>application/x-javascript</mime-type>
    </mime-mapping>

Also, there is no need to enable compression at Tomcat level, as it won't work when fronted by Apache/IIS.