Ø
the ASP.NET page can obtain information from within the
application.
Retrieving information from a resource outside the
application will require more processing steps, and will therefore require more
time and resources on the server than if the information can be obtained from
within the application space.
Now, suppose the information’s which sent to browser’s
have already been prepared then how faster the process of web-page.
The ASP.NET 3.5 Framework supports the following types
of caching:
- Page Output
Caching
Page Output Caching caches
an entire page.
- Partial Page
Caching
Partial Page Caching enables
you to get around this problem by enabling you to cache only particular regions
of a page.
- DataSource
Caching
You use DataSource Caching
with the different ASP.NET DataSource controls such as the SqlDataSource and
ObjectDataSource controls. When you enable caching with a DataSource control,
the DataSource control caches the data that it represents.
- Data
Caching
Finally, Data Caching is the
fundamental caching mechanism. Behind the scenes, all the other types of caching
use Data Caching. You can use Data Caching to cache arbitrary objects in memory.
For example, you can use Data Caching to cache a DataSet across multiple pages
in a web application.
Note:
The Cache object can also
have an expiration which would allow us to reinstitute data into the memory in
intervals. Using the same example as above, we can make the cache expire every
two hours, and repopulate the data. It would do this every 2 hours throughout
the day, allowing the most up to date data to be fetched. Below is an example of
how something can be put into the cache:
Referenced from
msdn
http://msdn.microsoft.com/en-us/library/system.web.caching.cache(VS.80).aspx
public void
AddItemToCache(Object sender, EventArgs e)
{
itemRemoved = false;
onRemove = new
CacheItemRemovedCallback(this.RemovedCallback);
if (Cache["Key1"] == null)
Cache.Add("Key1", "Value
1", null, DateTime.Now.AddSeconds(60),TimeSpan.Zero, CacheItemPriority.High,
onRemove);
}
public void
RemoveItemFromCache(Object sender, EventArgs e)
{
if(Cache["Key1"] != null)
Cache.Remove("Key1");
}
Application
Its nothing but similar to Session with a bit difference
that is Session objects have scope within a particular session while application
objects having scope within entire application.
Creating an application variable is similar to session
variables.
Application(“applictionObj”) = “This is an application
object”
Referenced
from msdn :
http://msdn.microsoft.com/en-us/library/bf9xhdz4(VS.71).aspx
|