Andy Davies

I'm running an all day Web Performance workshop in London on June 10th
Book your place with White October Events

.net and ISA Server - Reducing Bandwidth Consumption

Earlier this year I came across some problems with some .net resources not being cached by ISA Server (.net and ISA Server - a match made in hell?)

The problem in a nutshell is that by default ISA Server doesn’t cache URLs that have query parameters, and the method .net uses to serve static resources that are bundled in .dlls relies on query parameters.

When .net uses the Microsoft AJAX framework, script elements like the one below are inserted into the page

<script src="ScriptResource.axd?d=ki7GLYn2P5z-CEtE0SsvKYJhnTEkD13edwjg24cmxWe4aD03WzKyGXQD45nYCFy70&t=633178683580000000" type="text/javascript"></script>

After looking at some of the lastest developments in .net 4.0 I discovered that ScriptManager could be used to serve out static versions of the AJAX framework (even in versions of .net before 4.0).

After a few attempts I came up with this code that takes the ScriptResource.axd references in the page and replaces them with static scripts instead, which are of course generally cachable by ISA Server

<asp:ScriptManager ID="Script" runat="server" EnablePartialRendering="true">
      <asp:ScriptReference Name="MicrosoftAjax.js" Assembly="System.Web.Extensions" Path="~/js/ms/MicrosoftAjax.js" >
      <asp:ScriptReference Name="MicrosoftAjaxWebForms.js" Assembly="System.Web.Extensions" Path="~/js/ms/MicrosoftAjaxWebForms.js">

(the release i.e. minified, versions of the scripts within the MS AJAX framework have been placed in /js/ms)

By default the scripts won’t be served gzipped, or with the long expiry times that ScriptResource normally serves them with but this can be addresses by configuring IIS (which is how it should be in my view)

We’re still measuring how much this improves our page load times and how much it reduces our bandwidth consumption but it looks to make a significant difference.

If you’re interested Dave Reed has written more on what’s possible with ScriptManager in .net 4.0 - ASP.NET 4.0 ScriptManager Improvements