Application and Cache objects are used for storing static data for a certain period of time.Both use key-value pair format for data storage.
Both Application and Cache objects are one per web application.Their data can be accessed in all the pages of a web site.
Difference between Application object and cache object
1)Application object always stores data on the server side RAM
2)Application object maintains its data till the web application is shut down or we release the data manually by assigning null or Clear() method is called.
3)Application object has no Timeouts or File Dependencies.
4)Its data can be assigned using Global.asax file
5)Application object is not used for performance optimization.
USED in maintaining hit counters, data from readonly files/tables which can then
be displayed on varrious web pages.
1)Cache object can store the data on server side RAM as well as client side RAM
example: -- Cache["data"]="asp.net";
2)Cache object maintains the static data as specified by the Absolute Expiration/ Sliding Expiration or File Dependency. The Time Period for Cache can be defined using the Cache.Insert() overloaded method or Cache.Add() method. It can be from seconds to years.
3)Cache object can be assigned data from web page and not from Global.asax file.
4)Cache is used for performance optimization. We retreive the Cache data from
the Cache without repeating the full cycle again, which is not so in the case
of the Application object.
USES OF CACHE OBJECT:
1)Static images for a certain period of time
2)Calculating the time of the users who login in a certain period of time.
3)On line exams: store the questions in the Cache and then retreive them from Cache.