Tuesday, December 11, 2007

Sledgehammer for a nut Design/Process Pattern

I came across this the other day and thought that it was worth writing down as a pattern. In our specific example we wanted to control the client caching of our pages. The solution that the developer picked was to write an HTTPModule. (The reason for this was at least partly the 'If all you have is a hammer everything looks like a nail' pattern). It seemed at the time like overkill but I didn't have this pattern to apply...

Several weeks later we realize that none of our scripts are being cached on the client. This used to work but now it doesn't... The problem was of course that the HTTPModule was setting the cache control to no-cache for everything rather than just the pages we needed it set on.

The lesson to learn here is that to keep solutions focused but it you do need the big hammer to take extra care of avoiding collateral damage.