Enabling HTTP Compression under IIS

Bandwidth and faster websites are a big issue if you are looking for performance improvements. Compressing webpages is one of the most used thing to speed up your website.

Basically, your browser and your webserver must support compression to make it work. Since many people are using new browsers like Firefox, IE 7+, Safari, Opera and Chrome, we can setup our webservers to make it work.

Apache has been supporting this feature for a long time (using mod_gzip and mod_deflate), and Microsoft has released this feature on IIS since version 6. It is quite simple to enable:

  • Go to your webserver and open a dos prompt;
  • Point to your main inetpub\AdminScripts directory. In my case it was c:\inetpub\AdminScripts;

Now, we can execute some scripts to enable gzip compression. You can choose enabling this feature for static (html, css, jpeg, js) and dynamic content ( asp, aspx, asmx).

prompt> cd c:\Inetpub\AdminScripts

For static content

prompt> cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcFileExtensions “htm” “html” “js” “css” “xml” “xlt”
prompt> cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcFileExtensions “htm” “html” “js” “css” “xml” “xlt”

For dynamic scripts

prompt> cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions “asp” “aspx”
prompt> cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions “asp” “aspx”

To make things work out, we need a full IIS Reset

prompt> IISreset.exe /restart

IISreset may take a minute or two. After that, you need to test if your webserver is compressing your content. You can use firebug (a firefox plugin), or just point to WhatsMyIP.org HTTP Compression Test .

To finish, I suggest you to install Firefox (browser) and a plugin called YSlow (print screen below). It gives you great tips about how to improve your website performance, scoring things like number and size of css and js, position of js files, ajax requests, etc .

YSlow - An Yahoo Plugin for Firefox

YSlow - An Yahoo Plugin for Firefox

Hope it helps you!

-Robson Dantas

Bookmarksbookmark bookmark bookmark bookmark bookmark bookmark

Popularity: 3%

No Comment

Vale Presente