Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS 7.5 ASP.NET-4 Gzip compression

I just can't seem to get GZIP compression enabled for my ASP.NET 4 application. Only javascript files seem to get compressed. The page, css and others dont get compressed.

The response header of a not compressed CSS file is:

Content-Type      text/css
Last-Modified     Mon, 09 Aug 2010 20:10:34 GMT
Accept-Ranges     bytes
Etag               "5d71bdecfe37cb1:0"
Server    Microsoft-IIS/7.5
Date               Sat, 28 Aug 2010 14:33:56 GMT
Content-Length    3364

And for a Javascript file that gets compressed (scriptresource.axd):

Cache-Control      public
Content-Type       application/x-javascript
Content-Encoding gzip
Expires    Sun, 28 Aug 2011 14:33:50 GMT
Last-Modified      Sat, 28 Aug 2010 14:33:50 GMT
Server     Microsoft-IIS/7.5
Date                Sat, 28 Aug 2010 14:33:56 GMT
Content-Length     478

In applicationHost.config:

    <httpCompression sendCacheHeaders="false" directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" noCompressionForRange="true">
        <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
        <staticTypes>
        </staticTypes>
        <dynamicTypes>
        </dynamicTypes>
    </httpCompression>

And in the app web.config:

<urlCompression  doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="true" />
<httpCompression noCompressionForRange="false" noCompressionForHttp10="false" noCompressionForProxies="false" >
  <dynamicTypes>
    <add mimeType="text/css" enabled="true" />
  </dynamicTypes>
  <staticTypes>
    <add mimeType="text/css" enabled="true" />
  </staticTypes>
</httpCompression>

Can anybody tell me what setting I am missing?

like image 956
joop Avatar asked Aug 28 '10 14:08

joop


1 Answers

I found out what the problem was... In Turn Windows features on or off -> WWW -> Performance features, the static & dynamic compression was not enabled (pretty stupid).

The reason the Javascript was compressed is probably because ScriptResource.axd implements a custom gzip encoding.

like image 95
joop Avatar answered Oct 17 '22 04:10

joop