currently we are using Sessions to store datatables in our pages so that we don\'t have to make Database hits to get the same datatable again and again. But my worry is that
It is preferable to store "commonly used" data in Memory; that's good logic. However "Session" means that it exists for the life of that Session, and hence that user. Secondly, pending the user "Session" life, as you already said, this could be consume valuable resources on the Server Side.
What you may want to consider using is the "Cache" object, as it serves the same purpose with "Expiration".
DataTable users = new DataTable();
if (Cache["users"] == null)
{
// users = getUsers(customer);
Cache.Add(“users”, users, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 60, 0), System.Web.Caching.CacheItemPriority.Default, null);
}
else
{
sers = (DataTable)Cache["users"];
}
There are many ways to re-use memory in .NET (1) ViewState (2) Cache (3) Session (4) Cookies
But I would go for the "Cache" object.