about
framework & approach
knowledge network
news & events
technology council
why join?

Friday, June 23, 2006

ASP.NET 2.0 WebResource.axd and browser caching

We've launched our new public site (http://www.oceg.org) about a month ago now. Everything seems to be running smoothly, we're getting about 600 unique visitors a day, it's a pretty good start. However, we haven't been pleased with the overall performance. Page loads seemed abnormaly long, bandwidth useage unexpectedly high.

I found this neat little tool: Fiddler. Your can download it at http://www.fiddlertool.com. It's a debugging tool that catches every http request response sent/received by IE, with useful information about each one.

As I wrote in my previous post, we're using the ComponentArt Web.UI suite. Nice controls, but heavy javascript files. Since version 2006.1, those js files are serverd via WebResource.axd. That's a very nice addition, much easier to install, but Fiddler showed me that every WebResource.axd response had its caching set to "private", thus preventing caching to occur in the browser. Since we're using Menu and Grid together in a many pages, each client had to download at least 100KB of javascript upon every request!!

Workaround: I read Rick Strahl's post about this very same issue - http://west-wind.com/weblog/posts/4310.aspx. What you need to do is change the debug attribute in the compilation section of web.config to "false":

Caching is now "public", with expiration set to 1 year from original request date. I should be seeing our bandwidth useage shrink dramatically...

I also found some interesting info on Scott Gu's blog, like how to edit machine.config to ovveride the debug attribute on production servers. Cool stuff.

0 comments: