views:

28

answers:

3

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?

+2  A: 

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.

womp
If I cache the whole page, then user-specific information will be cached too. That will be a problem
Night Shade
If you read the documentation link I provided, it details several ways of customizing the OutputCache directive so that it caches by control ID, query string parameters, or even custom logic.
womp
+1  A: 

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

Ravia
+1  A: 

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.

Braveyard