Among techniques: static variables, viewstate, session and cache for staying away from on loading frequently and fewer making queries towards the database.

What is your opinion the best way from the 4 above? I Believe Cache is the greatest one? Or other techniques better in Asp.internet 3.5 or greater?

Please advise me about this.

Thanks ahead of time

When the data being retrieved is user specific, think about using Session. Whether it's exactly the same data shared of all customers, think about using the cache.

I'd discourage using view condition to cache database results since it rapidly blows up how big the made markup. In addition, view condition content mustn't simply be downloaded but additionally is Published to the server once the form is posted, so with view condition you have to pay the performance penalty two times.

An alternative choice you did not mention is by using the HttpContext.Products collection. This will make for a terrific way to cache database data per-request. This method is very useful for those who have many separate modules inside a page (like the master page and User Controls) which are locating exactly the same data, because it enables that data to become asked for once after which cached for that duration of that specific request. To learn more, make reference to HttpContext.Items - a Per-Request Cache Store.

There's not one response to your question. A seem data-access strategy that's made to be scalable and succeed will probably involve several as well as all the tools you mention, and perhaps others.

Clearly you won't use viewState when you really need persistent data throught a whole session, nor are you going to save per-user data in your soul application object.

viewState - per page
Session - per session (per user)
Application - per application
Cookie - per user (although not per session - rather throughout periods)

You'd usually make use of the Cache resist cache objects in application level..

That's about this.. Each one has another role.