简体   繁体   中英

Caching of Live Data

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, then 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM