Which is best to use: Cache object or static variables
1 answer
Using a cache has the advantage that you do not store objects in memory that are no longer in use (for example, using sliding / absolute expiration).
Additionally, ASP.NET can remove objects from the cache when the available memory gets low (which makes memory available).
If you are sure you are going to use some data all the time, then another alternative (to static variables) would be to use the Application object . This is the same as the Session object, but its data is global (for all sessions):
Application["myData"] = someData;
+1
a source to share