Difference between Session and Cache ?

 Posted by Bharathi Cherukuri on 4/20/2012 | Category: ASP.NET Interview questions | Views: 8020 | Points: 40

The main difference is session is per user, while cache will be for application scoped items.

1) Items put into a session will stay there, until the session ends, whereas Items in the cache can expire (will be removed from cache) after a specified amount of time. And also there is no guaranty that objects will not be removed before their expiration times as ASP.NET remove items from cache when the amount of available memory gets small. This process is called as Scavenging.

2) The session state can be kept external (state server, SQL server) and shared between several instances of your web app (for load balancing).
This is not the case with the cache.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Akiii on: 5/23/2012 | Points: 10
good explanation Bharathi...

Thanks and Regards
Posted by: Bharathi Cherukuri on: 5/24/2012 | Points: 10
Thanks Akiii


Login to post response