Live Chat Icon For mobile
Live Chat Icon

What are the pros and cons of using Session or Cache to save intermediate state?

Platform: ASP.NET| Category: Miscellaneous

To store in Session:

Pros:

  • It’s stored per user session
  • It’s just a handle to a live object, if using InProc
  • If you use StateServer or SQLServer mode, you can access your session state across the webform. (can’t use InProc mode in webform)

Cons:

  • If you use StateServer or SQLServer mode, your object must be serializable, and you pay the performance cost of network traffic + serialization cost

To use cache:

Pros:

  • It’s always stored as just a handle to the live object
  • Can use cache dependencies or other cache features to control its lifetime
  • Can be shared by all users on that web server

Cons:

  • It’s per app-domain per web server.

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.