HTTP Compression in IIS

When bandwidth becomes an issue, it is possible to enable HTTP compression between the web server and the browser. This increases CPU load on the web server by a small amount, but can provide fairly massive reductions in page sizes (in the order of 75%). Compression is part of the HTTP/1.1 specification, which means that […]

When bandwidth becomes an issue, it is possible to enable HTTP compression between the web server and the browser. This increases CPU load on the web server by a small amount, but can provide fairly massive reductions in page sizes (in the order of 75%). Compression is part of the HTTP/1.1 specification, which means that most browsers since 1999 support it. In the rare cases where a browser doesn’t support the technique, the server will discover this in the initial HTTP handshake and deliver uncompressed pages instead. To enable HTTP compression for your IIS webserver, changes are made to the IIS server settings. Note that while this will require a restart of IIS, it shouldn’t require CF to be restarted.

  1. Open the IIS Manager
  2. Expand the SERVERNAME section
  3. Right click on the Web Sites section and choose Properties from the menu
  4. Go to the Service tab
  5. Check Compress Application Files
  6. Check Compress Static Files
  7. Change Maximum Temporary Folder Size to 100MB (just to be safe)
  8. Hit OK

This has enabled HTTP Compression, but only Microsoft’s default file types. We want to add a couple extra static types (CSS and JS) and one very important application type (CFM), which is done through the IIS metabase. Open a command window Change directory to c:\inetpub\Adminscripts\ Type the following lines (or copy and paste):

cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcFileExtensions “htm” “html” “txt” “css” js”
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcFileExtensions “htm” “html” “txt” “css” “js”

Next we want to add support for CFM application file types, with these lines

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

Finally we apply these changes by restarting the IIS service

IISreset.exe /restart

Close the command window
To check that the changes have been successful, I use the Web Developer addon for Mozilla. The menu option to use is: Web Developer -> Information -> View Document Size This will show both the compressed and uncompressed sizes of all the elements on a particular page. Note that you may need to clear your cache to have the browser reload the compressed page elements if the old, uncompressed elements are present. CFHTTP Problems Unfortunately, there is a problem that occurs with compressed pages on IIS and cfhttp calls. IIS’s compression scheme is incompatible with CF and will result in a “Connection Failure” error. To fix this, we add these extra parameters to the cfhttp call, to let the server know that it shouldn’t use compression.

References

http://www.http-compression.com
http://www.eggheadcafe.com/articles/20020716.asp
http://www.talkingtree.com/blog/index.cfm/2004/7/28/20040729

Duncan Isaksen-Loxton

Educated as a web developer, with over 20 years of internet based work and experience, Duncan is a Google Workspace Certified Collaboration Engineer and a WordPress expert.
Login
Log in below to access your courses.
Log In With Google
Forgot Password
Enter your email address or username and we’ll send you instructions to reset your password.