Hi
Most of the time it is not practical to cache the entire
page, as and important section of the page is dynamically generated from the
database. But in those pages there is much content. As in my site the name of
the category and the number of post per month are fairly static (Until I add a
post or category). Since Output Caching caches the HTML or the entire ASP.Net
web page, it cannot be used for these scenarios. If I try and cache all the
posts (VaryByParam) then it will be a huge amount of cache in the memory and
might slow down the site further.
For these scenarios we can use Partial-Page Output Caching.
Specific regions of pages to be cached By Partial-Page
Output Caching, or page fragment caching. The Part of the page that we wish to
cache should appear in a User control. One way to specify that the contents of
a User Control should be cached is to supply an OutputCache directive at the
top of the User Control. That' it! The content inside the User Control will
now be cached for the specified period, while the ASP.NET Web page that
contains the User Control will continue to serve dynamic content.
The code is <%@OutputCache Duration="TimeinSeconds" VaryByParam="none"
%>
[Note that for this you should not place an OutputCache
directive in the ASP.NET Web page that contains the User Control - just inside
of the User Control.]
Hope this helps
Thanks
Vikram