In my previous post I've introduced YSlow – an Firebug’s add-on that helps to analyze and improve web site performance. One of the easiest ways to improve web application performance is to enable data compression. Enabling data compression on IIS 6.0 server can save up to 80% of network utilization by the price of up to 10% and often less than 1% of CPU ratio without changing single line of code.
Apparently, enabling data compression on IIS 6.0 is not that straight forward task as it looks. Most people that are using IIS as a hosting server mistakenly think that enabling data compression on “Web Sites properties” is enough… well it’s not – this is only the first step in that process.
So here is how it really goes step by step:
1. Enable compression functionality on IIS server management tool:
- Right click on “Web Sites” folder in IIS management tool , click on Properties
- Select Service tab in opened dialog
- Check “Compress application files”
- Check “Compress static files”
- Define a folder for compresses cache storage(possible to use a default)
- Select a limitation mode for compressed cache (Only compressed static files are cached)
2. Enable editing of meta data file manually:
- Right click on IIS root, click on Properties
- Check an “Enable Direct Metabase Edit” option
3. Edit meta data file:
The meta data file called MetaBase.xml is located at %windir%\system32\inetsrv\MetaBase.xml.
Changing MetaBase.xml can harm IIS server functionality if not handled properly, though it is crucial to backup file before making any changes.
XML compression configuration node name is “IIsCompressionScheme”. There are two such nodes in a MetaBase.xml file, one for Deflate compression algorithm and another for GZip compression algorithm – both nodes should be configured.
Attributes to be changed:
HcDynamicCompressionLevel attribute defines value from 0 to 10, when 0 is most light compression level. I would recommend to set it to 9 – it seems like an optimal “performance – compression ratio” relation.
Setting a compression level to 10 causes high CPU utilization.
HcFileExtensions attribute defines a list of static files extensions that should be compressed.(Example: js, HMTL etc.)
Do not enable data compression on files that are already compressed (jpg files for example).
HcScriptFileExtensions attribute defines a list of dynamic files extensions that should be compressed.(Example: aspx, asmx etc.)
Data compression feature is a very powerful tool for reducing network traffic, yet, no code changes are required! Still it is only one of many tweaks that are available on IIS server. About some of those I will blog very soon…