3

What's the difference between:

  1. HttpRuntime.Cache["key"]
  2. HttpContext.Current.Cache["key"]
  3. HttpContext.Current.Application["key"]

are there any major differences between these memories?

1
  • FYI, those are ASP.NET caches, not IIS caches. Commented Feb 5, 2014 at 10:15

1 Answer 1

1

HttpContext.Current.Cache and HttpRuntime.Cache are the same, the context cache prop just returns the runtime Cache. HttpRuntime and HttpContext just return handles to this object.

HttpRuntime.Cache is recommended but likely won't make a difference in most applications.

HttpContext.Current.Application is not a cache, its a global named value collection. if you add an object to Application it will stay until a an appdomain recycle. If you put an object in cache, it not guaranteed to be there when you fetch it. The cache is free to throw it away if the cache get too large, or the object has fetched often enough.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.