Web.config tricks

There are several things you can add to the web.config that will boost the performance of your ASP.NET website. Some of the tricks  works in all versions of the IIS and some only in IIS 7, but they all work in every version of ASP.NET.

HTTP compression


Not supported


You can compress both dynamic content like .aspx pages and static content like stylesheets and script files. If you use output caching, you probably need to compress dynamic content before caching. You can do all by adding this statement to the <system.webServer> element.

<urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="true" />

Beware that this IIS 7 feature might break some HTTP modules that changes the response. That's why it doesn't work with the WebOptimizer

Remove HTTP headers

The purpose of removing HTTP headers is not only to save some bytes on each response, but also from a security perspective. Headers that holds information about the server and software on it is always smart to remove.

IIS 6+7

Remove the version header from and save a few bytes on each response. The HTTP header looks like this:
X-AspNet-Version = 2.0.50727

Add the following to the <system.web> element:

<httpRuntime enableVersionHeader="false" />


You can also remove the X-Powered-By header by including these lines to the <system.webServer> element:

  <remove name="X-Powered-By" />

Disable unused modules

IIS 6+7

By disabling HTTP modules you don't use, you gain the lost CPU cycles associated with runnings them on every request. This is an example on how to remove some of the modules that you might not need. Add the following to the <system.web> element.

  <remove name="PassportAuthentication" />
  <remove name="Profile" />
  <remove name="AnonymousIdentification" />

See a more detailed explanation and list of default loaded modules.