We all agree output caching is a powerful feature - especially when applied to a user control. The downside is that it can be a pain to develop with - more often than not you want fresh data and waiting 6 hours (or even 5 minutes) for the cache to empty out sucks!
Well, thanks to the new output caching API, disabling output caching while developing is real easy. Here's a base user control I use for any control that'll have some output caching. When the DEBUG symbol is defined (ie, when you're in DEBUG mode), any @OutputCache directive will be overwritten by the code below, effectively disabling any caching.
public abstract class DevelopmentUserControl : UserControl
{
#if DEBUG
protected override void OnInit(System.EventArgs e)
{
CachePolicy.Duration = TimeSpan.FromSeconds(0);
base.OnInit(e);
}
#endif
}
Posted
03-27-2006 6:30 AM
by
karl