Gaurav Chutke
Gaurav Chutke

Reputation: 27

What should I prefer and which is faster to access, HttpContext.Application or HttpContext.Cache

I am getting huge amount of data which is frequently used and getting updated too on application start in MVC application. I would like to know,

  1. Which is faster to access, HttpContext.Application or HttpContext.Cache. What should I prefer.

  2. Where does HttpContext.Cache creates memory? in RAM or in Cache Memory of Server..?

Upvotes: 0

Views: 33

Answers (1)

SazooCat
SazooCat

Reputation: 170

Conceptually speaking..

Application is intended for data that is set ONCE per application (not necessarily at startup, maybe at point of first requirement), this exists across all user sessions/logins.

Cache is intended for data that MAY change, but can be valid for a cached period, after the period of time it will need to be re-fetched anyway.

Since you mention that your application needs to hold on to data that is being updated, this does not sound like a use for the Application object.

Upvotes: 1

Related Questions