Tuesday, October 31, 2006

ASP.NET Caching - Trick or Treat ?

It's a corporate internet web site which pulls content from database, idea is dynamic content but of course this doesn't change often. I was called to help with designing(!) some page so i used opportunity to learn about web performance, let me blog on what i found some other time.

As usual next thing is to cache page output, but there is a glitch (it is!), the web application also includes content mgmt logic as part of it and hence pages will be called with different querystring param for page previews.

<%@OutputCache Duration="60" VaryByParam="*" %>
is ruled out for two reasons 1 it is going to cache preview page output and 2 cache duration is dynamic. So i had to cache the page output based on querystring and in the code behind

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack = False Then
If Request.QueryString("noCache") Is Nothing Then
lblTime1.Text = "page cached on " & DateTime.Now.ToString()
Response.Cache.SetExpires(DateTime.Now.AddMinutes(60)) 'The duration will be dynamic
Response.Cache.SetCacheability(HttpCacheability.Server)
Else
lblTime1.Text = "page NOT cached " & DateTime.Now.ToString()
End If
End If
End Sub

If page loads with no querystring (normal user), it will be cached for whatever duration of time it needs to. If page loads from content mgmt logic (which will now include querystring noCache) it won't be cached. When i tested with following querystring, looked like it is working as expected

http://localhost/cacheTest/tst.aspx --page was cached for 60 minutes
http://localhost/cacheTest/tst.aspx?noCache=1&param1=abc --page is NOT cached

Struck with a question what will happen in following case

http://localhost/cacheTest/tst.aspx?param1=abc

Expectation is, it will be cached for 60 mins, since it didn't have noCache query string param. May be it will maintain a cached version for this combination of querstrings. But actually what turned out is different, it was spitting out message "page cached on " as it should, but subsequent page loads fetched me current time instead of first cached time, no idea how this is happening. Need to find out a way to see if this is caching multiple versions every time i load this page.

Happy Halloween.

Saturday, October 21, 2006

$0 PDA

I was listening to Soma's (MSFT) interview in Merina today, he quoted "... thing that is common to any human is *Time* ... everyone has only 24 hrs a day ...", if you think about it a bit, we can appreciate importance of time management, so here is my blog on poor man's personal organizer, IMHO pen on paper is simple and best.

With so many hifi PDA devices in the market, here is one which costs you nothing. You don't have to carry a charger, it won't annoy you with reminder chimes and best of all you don't have to write a fat check to get one. Before you decide to click the link, sit back and question yourself why you need a PDA, if you think of just a personal organizer, check these out PocketMod & D.I.Y Planner.

Saturday, October 14, 2006

Ajax WTH!

For last couple of weeks i got quite a lot queries from team on Ajax. Its more of a standard response from me "use it, if it makes sense!".

IMHO one has to weigh the Ajax features against the coding complexity. Enter enterprise apps scenario, you got lot of additional things to consider, most importantly code maintainability and alternate technology options. Comparing enterprise apps against google map, google spreadsheet, flickr is like comparing apples and oranges. I'd seriously consider SmartClient if we really needed a windows feel in web.

Bottom line, page postback is not always evil !

Sunday, October 08, 2006

search for code

I had a chance to try google/codesearch and i did get what i was searching for in first few tries, though it's a long way to go.

Update 12/17 : Even better one.

Friday, October 06, 2006

System.Transactions TransactionScope issue

I was having problem using this new model Transaction handling in .net 2.0, better than going to Enterprise services for just transaction handling, way it prmotes itself from Lightweight to full DTC XACT transparently helps a lot. Yeah i did bump into some posts pointing an bug that is currently open in this model, but that's not my issue today.

When i run the test app in Win XP SP2 connecting to 2 different SQL 2K server on Win 2K3, i got the following error "Network access for Distributed Transaction Manager (MSDTC) has been disabled." After some googling, enabled inbound/outbound transaction in DTC security settings and ended up with different error message, this happends when connection is opened
"The transaction has already been implicitly or explicitly committed or aborted", this one was tough, after lot of hit-n-miss i turned off firewall and it started working. Ahhhh.... WTH

Wednesday, October 04, 2006

hunt for bigfoot in code jungle

Moved a web app to be used by all N.A. employees of the client, for unknown reason app was throwing error for 2 employees out of whole population, unfortunately 2 guys are top brace, so we had to figure out the problem asap and i wrote DbTrace component to trace SAP function module calls for specified users and it all seems to be ok and i was out of the scene. Looks like support team was searching for the bug for more than a month and they keep coming back and questioning web app. Today it was found that 2 employee's user defaults are using non US notation and hence SAP was rejecting a valid numeric value 'coz it was expecting in different format, gahhh......

Monday, October 02, 2006

Rounded corners

Have you experienced editing the round corner image 'coz client decided to change the color of the rounded corner area, i happen to go thro one recently, considering my limited image editing knowledge somehow managed it.

Today happen to see this curvyCorners, js framework that provides this using few lines of javascript. As usual googling further found Atlas, ahem ASP.net Ajax sample. To make consistent coding practice and simpler server -side programming model, I'd prefer the later.

If think that is interesting, following should raise eye-brows, till now I'm also one of those millions who thought invisible table AKA table border="0" is only way to organize webpage layout, sit back and take a tour of CSS based design and why invisi table is bad. No idea if this is going to hit mainstream or not, but worth a try.