Sunday, October 25, 2009

Fragment Caching in ASP.NET

ASP.NET provides a mechanism for caching portions of pages, called page fragment caching. To cache a portion of a page, you must first encapsulate the portion of the page you want to cache into a user control. In the user control source file, add an OutputCache directive specifying the Duration and VaryByParam attributes. When that user control is loaded into a page at runtime, it is cached, and all subsequent pages that reference that same user control will retrieve it from the cache.



<%@ OutputCache Duration='60'
VaryByParam='none' %>
<%@ Control Language="'C#'" %>




Here I have user caching on user control, so when ever we used in a page , only partial page will be cached.

No comments:

Post a Comment

 
Locations of visitors to this page