12 February 2007
Enabling HTTP Compression with ASPX

Here's a quick-n-easy post about enabling HTTP Compression on your server, as I've done over the weekend.  But instead of reading endless blog posts about it, and MSDN articles about enabling each and every step, I've compiled it all into a single CMD script you can copy and run on your server.  Easy.

First a tiny bit of background...  Yeah, I am so late to this game.  For a while I heard the buzz word, but only thought it was similar to Analog Modem compression (back when I worked for Hayes) to where both modems must support a common compression algorythm, which was mostly never the case.  Hence the "Call these sets of numbers if you have a USR, call this number if you have a Hayes modem, etc" you may remember back in the modem days.

After reading up on HTTP Compression here this weekend, boy have I missed the boat.  I've enabled it on my server over the weekend, over most dynamic file types, and it's really picking up speed now (page loads seem faster).  I also found a nifty HTTP Compression Test website, that ensured me I finally got it enabled (it was a PITA for additional extensions).

Now the problem I had with HTTP Compression was the default list of extensions are very limited.  And it only does asp for dynamic content?  In IIE6?  You'd think they would default to aspx and asp.

Note that you will need to enable HTTP Compresison first, before running the attached script.  Instructions can be found here and just read the Procedures part. Don't worry about running the scripts in that article as the attachment takes care of that, and additional extensions.

The attached script enables static and dynamic compression types as listed below.  They are as follows:

Dynamic Types: ASP, DLL, EXE, ASPX, ASCX, ASMX, ASHX

Static Types: HTM, HTML, TXT, PPT, XLS, XML, PDF, XSLT, DOC, XSL, HTC, JS, CSS

You'll notice a few up for debate in that list, such as ASCX and PDF.  The debates ranged all over the web and saw it as an advantage more then disadvantage.  So over the next few weeks, I ask those I am hosting on my server to see if any dynamic content isn't so dynamic.  Kind of like a passive-monitoring approach by asking my users to see if they notice any difference.

About the PDF, some websites generate dynamic PDF content.  But usually it's just encoded as a PDF MIME-TYPE, and doesn't actually have the extension of PDF.  IIS6's HTTP Compression is based off of extensions, not the mime-type.  So I classified it as static.

A little script support.  First, this script assumes your OS is installed on C:.  And it assumes you have the file adsutil.vbs located at C:\InetPub\AdminScripts\ (default location).  If different locations, you can edit the script file as need be.  Besides that, you must be running at least W2K3 or R2 and as mentioned above already have HTTP Compression enabled.  Haven't tested this yet on IIS7 (Longhorn) yet.

 

Reader's Comments

I've sworn by HTTP compression for a while now myself...it was even one of my CS Tidbits a while back. Thanks for publishing this script!

# 12 February 07 5:49 PM
James Shaw said:

yeah, yeah, yawn. Welcome to last year Eric.

But seriously, where are these car posts? Enough "hi-tech" already. :)

# 13 February 07 2:43 PM

I don't know why you would want to enable compression on ASCX files.  You can't serve them outside of a page request...

# 08 March 07 12:57 AM

That's a good point Bill and one that is highly debated on the net.  But I believe the arguments are that the temp files created from compiling the ASCX file gets compressed, causing less server memory to serve-up the requested file.

HTTP Compression is more then serving up compressed files to the client's browser, which this I didn't know until I started to enable it.  IIS actually compresses each file, and stores a copy of that compressed file in a seperate directory for reference.

But after looking at the temp compressed directory on this server, I see there are no .aspx nor .ascx files in there.  Only static types listed above.

I will have to do a bit of research (or anyone else that wants to comment here) about how IIS compressed Dynamic content - i.e. where does it store them?  On-the-fly compression?

# 08 March 07 10:18 AM

Small update to my last comment.  I see that only static files show up in the temp directory - so I wouldn't see any aspx or ascx.  

# 23 October 07 2:07 PM

You should also add .axd to your dynamic list.

# 03 April 08 12:19 AM
Leave a Comment
Comment Policy: HTML is not allowed. Links and line breaks are converted automatically.
(required) 
(optional)
(required) 

 


  
Enter the anti-spam code you see above (required)

 

Comment Notifications
Subscribe to this post's comments using RSS

If you would like to receive an email when updates are made to this post, please register here