Difference between Session and Cache ?
Interview question and answer by: Bharathi Cherukuri
| Posted on: 4/20/2012 | Category: ASP.NET Interview questions
| Views: 1229 | | 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.
| Alert Moderator
Found interesting? Add this to: