开发者

Caching of Live Data

开发者 https://www.devze.com 2022-12-18 00:49 出处:网络
Suppose I have a grid view in an asp.net web page, where I am showing some data from a database. These data have to be updated every 20 seconds. If multiple users log in to the same page, they will se

Suppose I have a grid view in an asp.net web page, where I am showing some data from a database. These data have to be updated every 20 seconds. If multiple users log in to the same page, they will see the same data in that grid view. So, if, somehow I can cache those data, the开发者_如何学JAVAn it will be more faster in the multi-user scenario.

In my grid view, there are two columns, each displaying some floating point numbers, and I have 500+ of such rows.

How can I cache those data?


Use the OutputCache directive on your page.

<%@ OutputCache Duration="20" %>

This will keep the page in cache for 20 seconds, and the next time it is requested after the 20 seconds is up, it will be refreshed.


Why not use time dependent cache by setting Expirations (Time-based Dependency), check below links

http://aspnetcache.wordpress.com/2008/10/08/asp-net-cache-features/

http://msdn.microsoft.com/en-us/library/ms972379.aspx


You can either use partial caching or output caching.

If you don't want to cache whole page, you can use partial caching with Web User Controls. Your control will be cached when the other parts of your page is still refreshing which could be a good practice if you are working with GridViews.

More information about Partial Caching : http://bit.ly/9JME6G

Thanks.

0

精彩评论

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