Application: As in the preceding snapshots you see that the Application and Cache values are the same all over the application. Basically we use a static value in the Application Object that we want to show somewhere in the application that will be visible for every form in the Application.
We can use the Application Object in the global.asax file.
The Application Object maintains its data until the web application is shut down or we release the data manually by assigning null or call the Clear() method. The Application Object does not have any timeout.
Basically we use The Application Object to hit a counter on the Application, or read a readonly file or table to display in various web pages.
Cache: A Cache is very useful in web applications for performance optimization. Since application data can only be stored on the server, Cache data is stored on both the client side as well as the server side. We can define the time period for the cache using the Cache.Insert() or Cache.Add() method and the time period can be assigned from seconds to years. We even can maintain an absolute time expiration for the Cache.
We can assign value in the Cache only from web forms, not from the global.asax (we only can pass in the case of the Application and Session) file.
We retrieve the Cache data from the Cache without repeating the full cycle, which doesn't happen in the case of the Application.
And we can use the Cache if we want to calculate the time the user was logged in. Or if we are giving an online examination, then we can maintain the questions in the cache and retrieve them from there for better performance.
OR
We can use the Application Object in the global.asax file.
The Application Object maintains its data until the web application is shut down or we release the data manually by assigning null or call the Clear() method. The Application Object does not have any timeout.
Basically we use The Application Object to hit a counter on the Application, or read a readonly file or table to display in various web pages.
Cache: A Cache is very useful in web applications for performance optimization. Since application data can only be stored on the server, Cache data is stored on both the client side as well as the server side. We can define the time period for the cache using the Cache.Insert() or Cache.Add() method and the time period can be assigned from seconds to years. We even can maintain an absolute time expiration for the Cache.
We can assign value in the Cache only from web forms, not from the global.asax (we only can pass in the case of the Application and Session) file.
We retrieve the Cache data from the Cache without repeating the full cycle, which doesn't happen in the case of the Application.
And we can use the Cache if we want to calculate the time the user was logged in. Or if we are giving an online examination, then we can maintain the questions in the cache and retrieve them from there for better performance.
OR
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.
APPLICATION OBJECT:
1)Application object always stores data on the server side RAM
example: Application["hits"]=1;
(key-value pair).
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.
CACHE OBJECT:
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.
No comments:
Post a Comment