What is the difference between an HttpContext cache and element properties?

What is the difference between HttpContextclass Cacheand Itemsproperties?

In the MSDN documentation:

Cache
Gets the Cache object for the current application domain.

Elements
Gets a collection of keys / values ​​that can be used to organize and exchange data between the IHttpModule interface and the IHttpHandler interface during an HTTP request.

I really don't understand what this documentation is trying to explain.

While working on ASP.NET web applications, I often used Itemsto cache data for each request so that multiple user controls do not view the same data from the database. This is described in this article .

Today, although I came across using a property Cachefor what looked like caching on demand. I tried to understand the difference, but could not find good documentation by comparing the two. So I would like to know ...

What is the difference between the HttpContext Cache and Items properties? Try to explain examples of why you decided to use one above the other in different real-world scenarios.

+5
source share
1 answer

Elements per request, so it is available only to this user for this HTTP request. The cache is stored in memory for a constant period of time and is not dependent on a specific user. Thus, the cache can be used for several users for several requests, but the elements for each user per request.

, . , ObjectContext DbContext EF, . , .

+10

All Articles