Micah
Micah

Reputation: 116050

Setting the gzip compression in asp.net

Is there a way to set the gzip compression at the web.config level or can I only do this in the IIS management console?

Upvotes: 23

Views: 35899

Answers (2)

brenjt
brenjt

Reputation: 16297

Here try this: Sped my site up by about 400% percent. Worked on first try.

Activate GZip with web.config

<system.webServer>
  <httpCompression directory="%SystemDrive%\inetpub\
temp\IIS Temporary Compressed Files">
    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
    <dynamicTypes>
      <add mimeType="text/*" enabled="true"/>
      <add mimeType="message/*" enabled="true"/>
      <add mimeType="application/javascript" enabled="true"/>
      <add mimeType="*/*" enabled="false"/>
    </dynamicTypes>
    <staticTypes>
      <add mimeType="text/*" enabled="true"/>
      <add mimeType="message/*" enabled="true"/>
      <add mimeType="application/javascript" enabled="true"/>
      <add mimeType="*/*" enabled="false"/>
    </staticTypes>
  </httpCompression>
  <urlCompression doStaticCompression="true" doDynamicCompression="true"/>
</system.webServer>

Upvotes: 37

meandmycode
meandmycode

Reputation: 17317

Yes you can enable compression with the web.config, as the article below shows- but it can depend on the permissions on the server allows sites.

You should note that dynamic compression (anything that needs to be processed before ti can be sent to the client) can increase the load on the server because its having to do compression on every single request.

IIS7 Compression


Edit: note this is for IIS7 (as you have tagged)

Upvotes: 7

Related Questions