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 be load faster as it has to send compressed data.
How to enable gzip compression in IIS7
The first and most thing is to make sure the compression module is installed on not? check the below mentioned link for installation process.
http://www.iis.net/configreference/system.webserver/httpcompression
Basic steps to enable the HTTP compression on static Content
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 be load faster as it has to send compressed data.
How to enable gzip compression in IIS7
The first and most thing is to make sure the compression module is installed on not? check the below mentioned link for installation process.
http://www.iis.net/configreference/system.webserver/httpcompression
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.
Above steps must enabled 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 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 to 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 compressed automatically if other configurations are correct.