Tuning Microsoft IIS for PageSpeed

TCP Slow start server level tuning

See Optimizing TCP slow start.

Brotli compression

Brotli is a new compression algorithm by Google. We offer a free compression module that implements Brotli.

Static versus dynamic gzip compression

The recommended way to set up gzip compression on IIS is to turn off static compression, and enable dynamic compression. Static compression runs in front of the PageSpeed optimization module, and will only burn extra cpu cycles as PageSpeed has to decompress and recompress it in the optimization pipeline.

<system.webServer>
  <urlCompression doStaticCompression="false" doDynamicCompression="true" />
<system.webServer>

Gzip Mime types

There are a few mime types that IIS doesn't compress out of the box, which we recommend adding.

<system.webServer>
  <staticContent>
    <remove fileExtension=".woff" />
    <mimeMap fileExtension=".woff" mimeType="application/x-woff" />
    <remove fileExtension=".svg"/>
    <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
    <remove fileExtension=".svgz" />
    <mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
    <remove fileExtension=".json" />
    <mimeMap fileExtension=".json" mimeType="application/json" />
  </staticContent>
<system.webServer>

Gzip Compression when using a CDN with IIS

IIS disables gzip when a request has a "Via" header, which CDNs/proxies (rightfully) add. We recommend configuring IIS like this to make sure gzip compression is applied to assets served from the CDN.

<system.webServer>
  <httpCompression noCompressionForHttp10="false" noCompressionForProxies="false" />
</system.webServer>

Using a CDN with IIS: X-Origin settings

You can use PageSpeed optimization to rewrite all CSS, JavaScript and Images to have them served from the content delivery network. When doing so, you need to take care that the right headers are set to allow browsers to download (for example) font files from another location then where the html was served from.

<configuration>
 <system.webServer>
   <httpProtocol>
     <customHeaders>
       <add name="Access-Control-Allow-Origin" value="*" />
     </customHeaders>
   </httpProtocol>
 </system.webServer>
</configuration>