Caching a part of the page when most of the page is rendered dynamically

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


Share this post   Email it

Feedback

Posted on 11/12/2007 5:52:03 AM

Hi,

I'm using .net 2.0 + VSTO 2005.

I tried your code, however each process cpu% = 0 (zero), and this of course not right.

Any suggestions???

Posted on 5/29/2008 7:24:56 AM

for vshost.exe i'm getting cpu usage 100% and for all other apps it is showing 0%, how??

Posted on 5/29/2008 7:47:56 AM

when i try following code:

listBox1.Items.Clear();
Process p = Process.GetCurrentProcess();
using (PerformanceCounter pc = new PerformanceCounter("Process", "% Processor Time", p.ProcessName))
{
listBox1.Items.Add("Process: "+p.ProcessName + pc.NextValue());
}

It show CPU usage 0.

Please post your comments:

Name:  
Email (optional): Your email address will not be posted.
URL (optional):
Comments: HTML will be ignored, URLs will be converted to hyperlinks  
Enter the text you see in the box:
 

Copyright © 2006 - 2010 Vikram Lakhotia