.NET and ASP.NET interview question - Difference between Cache and Application?

 Posted by ArticlesMaint on 4/13/2011 | Category: ASP.NET Interview questions | Views: 2846

Application and Cache both help to share global data and cache data across the users.but cache object is proactive and you can define dependency.In application object you can't define depenency.

Below is the code for declaring application and cache object.

CacheDependency objCacheDependency = new CacheDependency(Server.MapPath("Banner.txt"));

Cache.Insert("Banner", strBanner, objCacheDependency);
Application["Banner"] = "strBanner";

In the above code, for Cache object you can define dependency but in Application object you can't define dependency.when the banner file is changed the Cache object can be refreshed but the application remain static and holds the old text of banner file.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response