5

What the difference between Application("some-object") and Cache("some-object") in ASP.NET?

Mark Glorie
  • 3,733
  • 3
  • 28
  • 31
Shawn
  • 19,465
  • 20
  • 98
  • 152

4 Answers4

9

Application is an application wide, no timeout (except when the pool restarts) dictionary. The cache is a temporary repository for common cache storage.

This And This might help clarify the differences and usages.

Here is another one.

Quintin Robinson
  • 81,193
  • 14
  • 123
  • 132
4

According to MS, Application storage is only preserved for backward compatibility with classic ASP applications so use the Cache because it's smarter and thread-safe.

bang
  • 4,982
  • 1
  • 24
  • 28
1

Application and cache are both application level storage of item, but difference is that in usage cenario , like cache is more flexible can do much more like scavenges ( removes unimortent item from cache automaticaly) ,but cache on othere side is volatilemeans that it is not sure that data will stay for application life .But Application is more relaibrel ,data stays when ever application is running but it is simple .

1
  • Application is very similar to a static dictionary that lasts for the lifetime of the web application.
  • Cache provides more features that you would expect in a cache, such as expiry and callbacks on expiry.
  • With the most common usage scenario, items can automatically 'disappear' from the cache. This does not happen with Application.
  • Cache appears to be the best practice option.
Community
  • 1
  • 1
Thomas Bratt
  • 48,038
  • 36
  • 121
  • 139