Configuring HTTP compression in IIS

HTTP compression, if accepted by a user browser, can significantly reduce traffic from your server. There are two types of compression offered by IIS, static content compression and dynamic content compression. If the static compression is enabled, then IIS will compress static content and save it to the cache folder. If the dynamic compression is enabled, IIS will compress content each time a client requests it, since dynamic content is created depending on a client request and because of it changes often. We recommend to enable both types of compression, you can do this in the following way:

  1. Open Internet Information Services (IIS) Manager.
  2. In the Connections pane select your Customer's Canvas application.

    Configuring HTTP compression in Windows Server 2012 and Windows Server 2012 R2.

  3. On the application's home page double click Compression and enable both, static and dynamic content compression.

    Configuring HTTP compression in Windows Server 2012 and Windows Server 2012 R2.

If static or dynamic compression is not installed on your server (the related option is disabled in IIS manager), you can install it like it is described below:

All HTTP compression configurations you can find in the <httpCompression> section of your application's pool configuration file, by default it looks like the following:

XML
<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>

Let us overview some parameters:

  • directory specifies the directory where compressed versions of static files are temporarily stored and cached.
  • scheme specifies the compression scheme (Gzip or Deflate), where name is the name of the scheme and dll is the path to the compression library. We strongly recommend to use GZIP, which is the default scheme.
  • dynamicTypes and staticTypes sections configure which files should be compressed. If you are going to change the default configuration, take into consideration, that some files, like JPG and PNG images, are already compressed, so there is no use to configure server to compress them.
Note

If a user browser cannot handle compressed content, it will receive uncompressed content, even if compression is enabled on the server side.

Windows Server 2012 and Windows Server 2012 R2

  1. Run Server Manager.
  2. In Server Manager, click the Manage menu, and then click Add Roles and Features.
  3. In the Add Roles and Features wizard, click Next. Select the installation type and click Next. Select the destination server and click Next.
  4. On the Server Roles page, expand Web Server (IIS), expand Web Server, expand Performance, and then select Static Content Compression and/or Dynamic Content Compression. Click Next.

    Configuring HTTP compression in Windows Server 2012 and Windows Server 2012 R2.

  5. On the Select features page, click Next.
  6. On the Confirm installation selections page, click Install.
  7. On the Results page, click Close.

How to Install HTTP Compression in IIS

Windows 8 or Windows 8.1

  1. Open Control Panel.
  2. In Control Panel, click Programs and Features, and then click Turn Windows features on or off.
  3. Expand Internet Information Services, expand World Wide Web Services, expand Performance Features, and then select Dynamic Content Compression and/or Static Content Compression.

    Configuring HTTP compression in Windows 8 and Windows Server 8.1.

  4. Click OK.
  5. Click Close.

Windows Server 2008 or Windows Server 2008 R2

  1. Run Server Manager.
  2. In the Server Manager hierarchy pane, expand Roles, and then click Web Server (IIS).
  3. In the Web Server (IIS) pane, scroll to the Role Services section, and then click Add Role Services.
  4. On the Select Role Services page of the Add Role Services Wizard, select Dynamic Content Compression if you want to install dynamic compression and Static Content Compression if you want to install static compression, and then click Next.

    Configuring HTTP compression in Windows Server 2008 and Windows Server 2008 R2.

  5. On the Confirm Installation Selections page, click Install.
  6. On the Results page, click Close.

Windows Vista or Windows 7

  1. Open Control Panel.
  2. In Control Panel, click Programs and Features, and then click Turn Windows Features on or off.
  3. Expand Internet Information Services, then World Wide Web Services, then Performance Features.
  4. Select Http Compression Dynamic if you want to install dynamic compression and Static Content Compression if you want to install static compression.

    Configuring HTTP compression in Windows Vista and Windows 7.

  5. Click OK.

See Also

Other