Karl Seguin

Sponsors

The Lounge

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Disabling output caching when developing
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
Filed under:

[Advertisement]

Comments

Jason Haley wrote Interesting Finds
on 03-28-2006 8:49 AM

Add a Comment

(required)  
(optional)
(required)  
Remember Me?