Monday, February 27, 2006

WebResource.axd Caching

While I'm hunting around to see how I can improve the bandwidth while I've used WebResource.axd embeded resource files extensively, it seems like the cache-control is always put as "private" which means it never get cached! even in the same page!

That's really a performance penalty.

After using fiddler to find out the fact, still don't have any clue since the AssemblyInfo's WebResource method doesn't give any option to caching customization. Thanks to Google again, I've got to Rick Strahl's WebLog on the issue of webresource.axd caching.

Basically, what happen is that when the library is compiled in debug mode, the caching is private (that means no caching) but while compiled in production mode, it will be public. Thank God, that means my codes will simply get its performance up when I switch over to production compilation.

Caveats about System.Diagnostics.StackTrace

This is a good site:
http://blogs.msdn.com/jmstall/archive/2005/03/20/399287.aspx

While I'm looking into self reporting of stack tracing of line from my framework, so that I can easily trace back to the line w/o throwing out unfriendly error message to surfer, use the stack trace class! .NET Rocks!

This is the codes I'ved used:
Dim sbMessage As New Text.StringBuilder
sbMessage.AppendFormat("Originating Host:{0}" & vbCrLf, System.Web.HttpContext.Current.Server.MachineName)
sbMessage.AppendFormat("User Host: {0}({1})" & vbCrLf, System.Web.HttpContext.Current.Request.UserHostName, System.Web.HttpContext.Current.Request.UserHostAddress)
sbMessage.AppendFormat("RawUrl : {0}" & vbCrLf, System.Web.HttpContext.Current.Request.RawUrl)
sbMessage.Append("Stack Trace:" & vbCrLf)
Dim st As New StackTrace(True)
For Each stEntry As StackFrame In st.GetFrames
sbMessage.Append(stEntry.ToString & vbCrLf)
Next

Subsequently, send it to your mailbox using System.Net.Mail.SmtpClient(), and you've got your own error reporting machanism.