开发者

ASP.NET recreating cached control

I solved most of the issues I had with caching. But still there开发者_开发百科 is one thing. I have a UserControl for which I use output caching. Just like this:

<%@ OutputCache Duration="1200" VaryByParam="none" %> 

However, as you can see, the control is recreated every 12 minutes, because it takes from 5 to 10 seconds to generate it.

Now, the default behavious for ASP.NET is to create the control when user enter the page and keep it in cache for 12 minutes. Then when after another 5 minutes user enters the page the control is created again.

Is there a way to force ASP.NET to recreate the control after the 12 minutes cache expires? No matter on the next user visit?

Or even a perfect solution: recreate control in background after lets say 11 minutes 50 seconds, and than just replace the actual one with the new one after 12 minutes?

Thanks for help!


Use Windows Scheduled Tasks to enter this page every 12 minutes because ASP.NET works with triggers only. Trigger can be either Ajax that requests other page every 12 minutes or next user that comes to your webpage.


I'm not sure, but it sounds like you want your control to be updated asynchronously at intervals while the user is viewing the page?

If so, you'd need to use Ajax. For example, the Timer control allows UpdatePanels to be asynchronously updated at set intervals.

By the way, the duration you have in your example is actually 20 minutes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜