Tuesday, 26 March 2013

Improving website performance via GZip compression and 304 redirects

If you look at TeamMentor’s traffic (using for example Chrome developer tools), you will see that (for the version https://tm-www.azurewebsites.net ) on the 2nd load, there will only be about 307k downloaded in about 8secs:

image

And that is for a TM site with a large set of libraries.

For the cases where a small(er) library is hosted, it is even faster and smaller.

In https://tm-services.azurewebsites.net we have 35k and 3.3 secs

image

This is achieved via two techniques: Gzip Compression and 304 redirects.

They can be controlled by these two TMConfig settings:

image

The 304 redirects affect the ScriptCombiner handler (used to combine and minify Javascript files), and is used here:

image

The send304Redirect method checks if there is a If-Modified-Since header, and if there is one, it checks the date:

image

The Last_Modified_HeaderDate will be set on the static .ctor of the ScriptCombiner class (i.e. once per server/process start)

image


The GZip compression is handled by:

image

which is called on the .ctor of the main TM_WebServices class:

image