C# – Data cache vs session object in ASP.Net

asp.netccachingsession

Should dynamic business objects for a site be stored in the users session or use ASP.Net caching (objects such as orders, profile information etc)?

I have worked with sites that used sessions to store business objects, but I was wondering…What are the advantages or disadvantages of caching?

Best Answer

If the objects are shareable between user sessions, then use the cache. If the objects are unique to each session -- perhaps because they are governed by permissions -- then store it in the session. The in-process session itself is stored in the cache so the deciding factor really should be the scope of the data.

Related Topic