Tuesday, 18 November 2014

Caching In Asp.Net

Caching is the ability to store page output and data in memory for the first time it is requested and later we can quickly retrieve them for multiple, repetitious client requests. It is like keeping a copy of something for later use, so we can reduce the load factor on Web servers and database servers by implementing caching on a Web application.
Writing Code In C#
Cache.Add("dataset", dataset, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 0, 60), System.Web.Caching.CacheItemPriority.Default, null);

Retrieve data from cache
Writing Code In C#
DataSet ds = new DataSet();
ds = (DataSet) Cache["dataset"];
It becomes more efficient to serve a copy of the initial response, rather than regenerating the same response for every client request.
ASP.NET provides two types of caching, Application Cache and Page Output Cache. The application cache, which provides a programmatic way for you to store arbitrary data in memory using key/value pairs. The Page output caching, which saves the output of page processing and reuses the output instead of re-processing the page when a user requests the page again.


Post a Comment

Copyright © DotNet-Ashok