Posted At : 19 September 2007 10:48 | Posted By : Duncan Loxton
Related Categories:
ColdFusion,
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 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.
- Open the IIS Manager
- Expand the SERVERNAME section
- Right click on the Web Sites section and choose Properties from the menu
- Go to the Service tab
- Check Compress Application Files
- Check Compress Static Files
- Change Maximum Temporary Folder Size to 100MB (just to be safe)
- 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.