Speeding up page impressions
I had cause to review a web servers performance recently after it was noted that one site was being served extremely quickly to the client and the other seemed woefully slow.
Well the webserver in this case was IIS 5 but the ideas discussed are relevant to other webservers such as Apache.
Firstly utilising a couple of excellent plugins for the FireFox 3 browser, namely Firebug and YSlow for Firebug, I was able to instantly see performance stats about how a server is serving a page to the client.
It was clear that the site I was reviewing wasn’t using any settings for caching and also wasn’t using gzip compression for on the fly compression of the HTTP response.
These sorts of thing can generally be set in a number of ways – either in server side script or configured for a given resource.
So, to summarise the changes I made in IIS for this site, I made sure all images were being stored in a folder called images from the root of the site. Then from IIS snapin right click the folder and choose properties, choose the HTTP Headers tab and enable content expiration for images.
Next I enable gzip compression by right clicking the computer icon in IIS and clicking properties, then choosing Edit under Master Properties and clicking on the Service tab – yeah pretty well hidden away really.
Under IIS if you choose to “compress application files” only the following will be compressed “asp”, “dll”, “exe”, I know this is true of IIS 6 as well as IIS 5 – search google for “Customizing the File Types IIS Compresses” to see how to get round that – you’ll likely want to add aspx and php if your server is supporting them.
Here’s the contents of a batch file that can be run on the server to set this up, just make sure that adsutil.vbs is available where the script is looking.
IISreset.exe /stop
cd c:\Inetpub\AdminScripts
cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoDynamicCompression true
cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcFileExtensions "htm" "html" "txt" "ppt" "xls" "xml" "doc" "js" "css"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcFileExtensions "htm" "html" "txt" "ppt" "xls" "xml" "doc" "js" "css"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx" "ashx" "php"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx" "php"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcDynamicCompressionLevel "9"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcDynamicCompressionLevel "9"
IISreset.exe /restart