23

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?

1

2 Answers 2

37

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>
Sign up to request clarification or add additional context in comments.

7 Comments

Tried several times but if these settings are set in web.config, compression does not work. If settings are set in applicationhost.config, everything works. I do not like to set settings in applicationhost.config, but at least it is working.
My shared hosting provider manages my permissions using Plesk and got this solution to fail for me too. I've explained in short the lengthier solution I put-together at stackoverflow.com/a/14509007/1624169
Microsoft agrees. iis.net/configreference/system.webserver/httpcompression But this appears to already be setup by default when you install gzip compression so this step should be unnecessary, and it only minifies content like js, not the HTML of ASP.Net pages.
HTML not gzipping even after the above turns out to be the fault of this obscure setting: stackoverflow.com/a/15626981/176877
If Javascript isn't compressed, try the MIME type "application/x-javascript" instead.
|
7

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)

1 Comment

This change will gzip js and css, but not the actual HTML output from ASP.Net, for some reason. You'd thing setting dynamic content compression to enabled would do the trick, but in my testing it does not.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.