Scott Hanselman

"Attaching a CacheDependancy to a ASP.NET Page using Output Caching" or "I can't believe they didn't think of this...oh sweet, they did!"

February 20, 2003 Comment on this post [2] Posted in Web Services | ASP.NET
Sponsored By

ASP.NET caching This seems like an obvious thing to want to do, but I can't see how. I have a bunch of pages using OutputCaching, like <%@ OutputCache Duration="600" VaryByParam="none" %> but the pages use additional data points / files that I'd like to add as additional cache dependencies. I can create the extra CacheDependency objects, but can't see how to connect them up to the cache entry for the page. I can't beleive the ASP.NET guys didn't think of this.[Simon Fell]

Simon is looking to add a CacheDependancy to a ASP.NET Page using Output Caching, he'll need to use HttpResponse.AddCacheItemDependency and HttpResponse.AddCacheItemDependencies

The most interesting thing about what Simon says is "I can't believe the ASP.NET guys didn't think of this."  That's funny, because I know as well as anyone that the Microsoft guys aren't perfect, but when it comes to the .NET Framework, I'll tend to search just a little harder on the faith that what I need HAS to be there...because they must have thought about this.  As you spend time with the .NET Framework you'll increasingly get that same attitude; they really did think this thing through.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
February 20, 2003 12:55
I think Simon's doubt was that you can declaratively set the cache to key off params, but not declaratively set things like file dependencies. I don't think he thought this through, however, since that could become a nightmare in some deployment scenarios.
October 11, 2005 11:48
It all depends how you read "I can't beleive the ASP.NET guys didn't think of this". He may have being saying it in a ".NET is so good that there must be a way to do this..." rather than a "I hate M$" vent :)

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.