Welcome to EMC Consulting Blogs Sign in | Join | Help

Howard van Rooijen's EMC Consulting Blog (2004 - 2010)

This blog has now moved to http://howard.vanrooijen.co.uk/blog - please update your subscriptions if you wish to receive new content.

On optimising web content...

One of the first tasks we’ve undertaken on my new project is a performance review of the legacy web application. Performance improvements are very rarely obtained by changing a single setting on a server (although this has been known) but are more generally the aggregated total of a number of minor performance improvements. The “shavings” we’ll focus on are around the size of files being downloaded.

Firstly, run Fiddler against the site – this generates a report of all the requests made, their sizes and whether they are marked as cached or are compressed. Fiddler has a neat feature which allows to “turn on” HTTP compression for a given request to estimate how much the file size is reduced. For more information on using Fiddler, see the Fiddler Power Toy articles Part 1 & Part 2 on MSDN.

HTTP Compression will make a huge amount of difference in transfer speeds – especially if you are using ASP.NET and have a lot of session state. There are several good articles that describe enabling HTTP Compression on IIS and ISA Server. Make sure you enable compression for the following file types:

  • .js
  • .css
  • .htm
  • .html
  • .aspx
  • .axd (an easy one to forget – but this is important if you are using ASP.NET 2.0 as resources such as DetailsView.js, Focus.js, GridView.js, Menu.js, SmartNav.js, TreeView.js, WebForms.js, WebParts.js and WebUIValidation.js are served via a HTTP Handler – WebResource.axd)

Next, look at the files that were actually being downloaded – the site had two CSS files which were separated purely for ease of maintenance; they were about 60 kb in size. These were then merged into a single file and were passed through a free tool called CSSTidy which can reduce CSS file size by stripping out unnecessary whitespace and optimising style statements; for example:

{margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;}

becomes

{margin:10px;}

It will also perform optimisations across multiple classes – which is where the big savings are generated. The tool showed that we could reduce the file size by ~60%, but once optimised it would be very difficult to update or add to, so we added this optimisation as a step in our nightly build process – so the optimisations were only applied to our test and live environments – not development. The MSBuild step used is listed below:

<Exec Command="C:\Tools\CssTidy.exe C:\Inetpub\wwwroot\test\Style.css -template=highest_compression C:\Inetpub\wwwroot\test\Style.css"/>

Apply the same process to the JavaScript files, but this time using a free tool called Jazmin – the JavaScript minimizer, which strips out unnecessary whitespace and comments. Again this was added to the nightly build process using an MSBuild Exec task. Again this tool managed to reduce file sized by anything up to 40%.

Published 23 February 2006 20:49 by howard.vanrooijen
Filed under: ,

Comment Notification

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

Subscribe to this post's comments using RSS

Comments

 

Harry Chou said:

Thank you. I visited your blog for Scrum and Team System info. Yet, this post is absolutely the clearest for web content performance tuning.
March 27, 2006 17:56
 

Harry Chou said:

One question: What is the reason behind this statement:

... HTTP Compression will make a huge amount of difference in transfer speeds – especially if you are using ASP.NET and have a lot of session state....

What is the relationship between session state and HTTP Compression?
March 27, 2006 17:59
 

howard.vanrooijen said:

There is no relationship between HTTP Compression and Session State AFAIK - HTTP Compression simply squishes up the data in transit from the server to the client. Session State is held on the server (either in memory or in SQL Server).

HTTP Compression will reduce ViewState size - but this can also be zipping up the view state - for example - http://www.hanselman.com/blog/ZippingCompressingViewStateInASPNET.aspx
March 27, 2006 18:07
 

Lars Buur said:

Would very much like to know if anyone has an idea on how to use the same methods in xslt files.

January 12, 2007 16:50
 

Atif Aziz said:

Howard, the latest Jazmin update and download now comes with a custom task for MSBuild. See:

http://www.raboof.com/projects/jazmin/

January 18, 2007 07:34
 

howard.vanrooijen said:

Atif,

This is great news! Thanks for the update.

January 24, 2007 08:26

Leave a Comment

(required) 
(optional)
(required) 
Submit

This Blog

Syndication

News

This blog has now moved - please visit http://howard.vanrooijen.co.uk/blog for new content!
Add to Live.com
Powered by Community Server (Personal Edition), by Telligent Systems