To optimize the performance of my WindowsAzure web role I analysed it with the firefox plugin page speed. To pass the several tests I needed to enhance the following settings.

Leverage browser caching:

<system.webServer>
    <staticContent>
      <clientCache httpExpires="Sun, 29 Mar 2020 00:00:00 GMT" cacheControlMode="UseExpires" />
    </staticContent>

I changed the above setting to:

<system.webServer>
    <staticContent>
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00"  />
    </staticContent>

Because it is strongly not recommend to use high expiration dates, because you can not influence client or proxy cache if the file is already cached. In this example it set it to 1 day.

More Information here.

Specify a Vary: Accept-Encoding header:
<system.webServer>
	  <httpProtocol>
	    <customHeaders>
		    <remove name="Vary"></remove>
		    <add name="Vary" value="Accept-Encoding"></add>
	    </customHeaders>
	  </httpProtocol>

Also I changed here a little bit:

<system.webServer>
	  <httpProtocol>
	    <customHeaders>
		    <remove name="Vary"></remove>
		    <add name="Vary" value="Accept-Encoding, Cookie"></add>
	    </customHeaders>
	  </httpProtocol>

Cookie means in this case to use a different cache version for each session.

EDIT: I removed the “Cookie”-Setting again, because it slows down every page request up to 2  Seconds!

More information here.

Enable compression:

<system.webServer>
    <staticContent>
      <remove fileExtension=".js" />
      <mimeMap fileExtension=".js" mimeType="text/javascript" />
    </staticContent>

    <httpCompression
        directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files"
        cacheControlHeader="max-age=86400"
			  noCompressionForHttp10="false"
			  noCompressionForProxies="false"
			  sendCacheHeaders="true"
                          minFileSizeForComp="0">
      <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
      <dynamicTypes>
        <add mimeType="text/*" enabled="true" />
        <add mimeType="message/*" enabled="true" />
        <add mimeType="application/x-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" />

Not that httpCompression is already enabled by default, but the default setting for minFileSizeForComp ist 2700kB, so small files will be ignored. Furthermore I disabled the compression for HTTP1.0 and Proxies, because older browser sometime have problems with it.

The modification of the mimeMap is done because of the different mimeTypes for JavaScript, so we give all .js files the same mime type which will be compressed.