Enabling GZip compression in IIS 5 (Win2000 and not XP) for ASP.Net files
Maybe it works for other IIS versions as well, but I certainly was looking for a way of turning it on on our Windows 2000 development/test computer. So this is the long story:
HOW TO: Enable ASPX Compression in IIS
and this is the short one:
Step 1: backup your site metabase
Go to the Internet Information Services (IIS) tab and right click on it, go to All Tasks, choose Backup/Restore Configuration and save it.
Step 2: make the change to the metabase
Create a .bat file that has the following content:
Make sure to restart the SMTP service or any others that were stopped by the bat. I don't know how to start it from the command line and I pretty much don't care. The batch file will notify you of possible services it will shut down, but will restart in the end only the Web service.
The performance is immediately visible and it also works with Ajax.
Update:
This article was originally talking about Windows XP. Thanks to McHilarant (see comment below) I realized that, even if the changes in the metabase are possible on any IIS5 (Windows XP and Windows 2000), the actual compression will not be possible on XP. I remembered then that the actual modification that I did that time was not on my dev machine, but on our office server, therefore I updated the post accordingly.
Another Update:
Here is a link about a script to enable IIS 6 gzip compression: Script to Enable HTTP Compression (Gzip/Deflate) in IIS 6.
HOW TO: Enable ASPX Compression in IIS
and this is the short one:
Step 1: backup your site metabase
Go to the Internet Information Services (IIS) tab and right click on it, go to All Tasks, choose Backup/Restore Configuration and save it.
Step 2: make the change to the metabase
Create a .bat file that has the following content:
net stop iisadmin
cd C:\InetPub\adminscripts
CSCRIPT.EXE ADSUTIL.VBS SET W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions "asp" "dll" "exe" "aspx"
CSCRIPT.EXE ADSUTIL.VBS SET W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "dll" "exe" "aspx"
net start w3svc
Make sure to restart the SMTP service or any others that were stopped by the bat. I don't know how to start it from the command line and I pretty much don't care. The batch file will notify you of possible services it will shut down, but will restart in the end only the Web service.
The performance is immediately visible and it also works with Ajax.
Update:
This article was originally talking about Windows XP. Thanks to McHilarant (see comment below) I realized that, even if the changes in the metabase are possible on any IIS5 (Windows XP and Windows 2000), the actual compression will not be possible on XP. I remembered then that the actual modification that I did that time was not on my dev machine, but on our office server, therefore I updated the post accordingly.
Another Update:
Here is a link about a script to enable IIS 6 gzip compression: Script to Enable HTTP Compression (Gzip/Deflate) in IIS 6.
I tried this, batch file successful, but firebug still says gzip is not enabled. Did something change in XP SP3 possibly?
ReplyDeleteWell I also tried the above mentioned steps and configured IIS for compression.
ReplyDeleteBut when I post back a page with AJAX Panel the response header says
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Wed, 19 Aug 2009 12:39:27 GMT
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Pragma: no-cache
Transfer-Encoding: chunked
Cache-Control: no-cache, no-store
Pragma: no-cache
Expires: -1
Content-Type: text/plain; charset=utf-8
Thus I don't see
"Content-Encoding: deflate" or "Content-Encoding: gzip" in the response and it seems the response is not compressed.
Are you sure you have IIS5 (XP) ? If it is a web server it is at least IIS6. There is another solution for different versions. My blog post covers the most difficult and obscure one, version 5.
ReplyDeleteThanks for your prompt response.
ReplyDeleteYes its XP Professional SP3 Machine.
Also response header says its "Server: Microsoft-IIS/5.1".
I don't know then. If you find that the blog post is not complete/correct and you find out what was wrong, please let me know.
ReplyDeletesee this
ReplyDeletehttp://support.microsoft.com/kb/308168
no compression on xp possible.
Very interesting article. Thanks. I think when I tested it it wa actually on an Win2000 machine. Now I feel stupid :)
ReplyDeleteIs there any reason you would NOT want to enable this for htm files?
ReplyDeleteThe post is about enabling it for dynamic files, like .aspx files and such. .htm is a static file and it can be compressed without too much complication.
ReplyDelete