IIS 7.5 Not Compressing Javascript: NO_MATCHING_CONTENT_TYPE

compressioniis-7iis-7.5javascriptwindows-server-2008

I have IIS 7.5 set to compress all static files (the default), yet it does not compress .js (javascript) files. When I turn on failed request tracing for compression, the error I get for the compression is:

NO_MATCHING_CONTENT_TYPE

I read about this, and the only solution I saw posted was to make sure application/x-javascript (and not just application/javascript) is specified as a mimetype seen as 'static' content. So I adjusted my applicationHost.config to have this:

    <httpCompression>
        <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" dynamicCompressionLevel="5" />
        <scheme name="deflate" dll="%windir%\system32\inetsrv\gzip.dll" />
        <staticTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/javascript" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </staticTypes>
    </httpCompression>

However, I still see the same error in failed request tracelogs: NO_MATCHING_CONTENT_TYPE. Any other ideas?

Best Answer

Make sure that you have .js files mapped to one of these MIME types (e.g. application/javascript'), and not something else entirely, e.g.text/javascript`. (If you just issue a HTTP request using something like curl or wget against one of these files as a client, what MIME type is the server returning it as?)