Enable gzip compression with web.config

HTTP compression can reduce the amount of time it takes to download the resources needed to render your web site.
You can directly enable gzip compression for your asp.net website by adding the following lines in web.config’s system.webServer section:
[code lang=”xml”]
<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>
[/code]
This configuration will enable gzip compression on static and on dynamic content. I have tried it on Windows Shared Hosting and it worked fine.

Browser caching for static resources can save a user time if they visit your site more than once, so include explicit caching headers.
And since you already have the file open, to further improve performance and to squeeze out every byte from your headers, do the following:
[code lang=”xml”]
<system.webServer>

<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="max-age=0" />
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
</staticContent>
</system.webServer>
[/code]

Because there’s no reason not to strip these headers out:
[code lang=”xml”]
<system.web>

<httpRuntime enableVersionHeader="false" />
</system.web>
[/code]

Revealing the specific software version of the server may allow the server machine to become more vulnerable to attacks against software that is known to contain security holes. Implementers SHOULD make the Server header field a configurable option.

You can test your site with PageSpeed now!