Click here to Skip to main content
15,886,806 members
Articles / Web Development / IIS
Technical Blog

How to Enable gzip Compression in IIS7

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
2 Nov 2019CPOL2 min read 6.6K  
How to enable gzip compression in IIS7

Overview

Gzip compression is used to compress your content and then deliver to client. Today's modern browser supports compression. So it is a good idea to deliver the static content after compression, this way you can save lots of bandwidth and your page will load faster as it has to send compressed data.

How to Enable gzip Compression in IIS7

The first and foremost thing is to make sure whether the compression module is installed on not? Check the below mentioned link for installation process:

Basic Steps to Enable the HTTP Compression on Static Content

  • Start > Run > Inetmgr > hit Enter
  • Select your web site
  • In Features View, double click Compression
  • Check the Enable Static content compression
  • Click Apply in the Actions pane.

The above steps must enable the static compression and your js, css, etc. static contents should be compressed.

Exceptional Settings

Sometimes, you will not get your content compressed after doing the above mentioned steps. I recently got the experience and I would like to share the solution with you.

Set Read Permissions to applicationHost.config File for IIS_ISURS Group

  • You will find this file at C:\Windows\System32\inetsrv\config
  • Right click on this file and click properties, now click on security tab
  • Now click on Edit button
  • Now click on Add button under Group or user name
  • Now enter IIS_IUSRS
  • Click Check Names button
  • Now Select Read & Execute and Read permission
  • Click Apply, then click OK

Check the httpCompression Types

Check the httpCompression section in applicationHost.config file, you should find <add mimeType="application/x-javascript" enabled="true" />. If this is correct, then it should be correctly configured in your IIS.

  • Now go to IIS Manager and select your site
  • Click on Features View from bottom
  • Now click on MIME Types
  • Find the .js entry
  • If the .js extension has MIME Type = "application/javascript", then remove that entry
  • Now click Add from Actions pane
  • Give extension as .js
  • Give MIME type as application/x-javascript
  • Click Apply
  • Restart the website

This will start compressing your .js files.

.css files would be compressed automatically if other configurations are correct.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Product Manager Netclues Technologies India Pvt. Ltd.
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --