Caching is the process of storing frequently used data and information in memory. so that,when the same information or data is needed next time, it could be directly retrieved from the memory instead of being generated by the application. Caching is one of the most important technique in creating a high-performance and scalable web application.
Trending Now : Advanced Features of Dot Net Framework
How to create data cache?
Cache[“Student”] = “DataSet Name”
We can create data caching use Cache Keyword. It’s located in the System.Web.Caching namespace. It’s just like assigning value to the variable
How to Read data from Data Cache?
Dataset dsStudent = (Dataset) Cache [“Student”]
This is very similar to assigning object to the Dataset.
Where does Data Cache are stored?
In Data Caching this is one of the interesting things to find out the Data Caching in your local drive. First , From “Internet Explorer Internet Option “, delete Browsing History to clear Cache.
How to remove a Data Cache?
We can remove Data Cache manually.
Caching in Asp.Net:
ASP.NET provides the following types of caching:
- Output Caching
- Data Caching
- Object caching
Output Caching :
Output cache is used to store a copy of the last whole rendered HTML pages or part of pages sent to the client. When the next client requests for that page, instead of regenerating the page, a cached copy of the page is sent, thus saving time.
Syntax for OutputCache
<%@ OutputCache Duration=”15″ VaryByParam=”None” %>
Data Caching :
The important part of data caching is caching the data source controls. The data source controls represent data in a data source, like a database or an XML file. These controls derive from the abstract class DataSourceControland have the following inherited properties for implementing caching
Object caching is used to provides flexibility than other cache method. You can use object caching to place any object in the cache. In that Caching the object can be of any type a data type, a class, a dataset object. The item is added to the cache simply by assigning a new key name, shown as follows Like
Cache[“key”] = item;
Caching can provide huge performance benefits to Web applications, and should therefore be considered when an application is being designed as well as when it is being performance tested. A perfect understanding of the caching options available in ASP.NET is an important skill for any ASP.NET developer to master.