Caching in ASP.Net

-> An application can often increase performance by storing data in memory that is accessed frequently and that requires significant processing time to create.
-> Caching is the process of storing data, pages or parts of a web page in memory so that they can be retrieved faster than they could be accessed from a file or a database. This helps to improve performance and increase scalability of a web application. For e.g., if you have an e-commerce website with a product catalog, you can cache huge part of the catalog. Data that changes infrequently but it is accessed by a lot of users is a good example of what you can cache.
-> The first request to the data stores it in the cache and subsequent requests are served from the cache until the cache expires.
-> ASP.NET provides caching using two basic caching mechanisms.

1) Application caching
 -> represents a collection that can store any object in memory
-> allows us to cache data generated such as DataSet object or custom report business object.
-> Caching is implemented by the Cache class, with each instance private to each application. The cache time is tied to that of the application; when the application is restarted, the Cache object is recreated.
-> The cache is available as a page property. It represents a collection of class of type System.Web.Caching.Cache.

2) Page output caching
 -> Where a page or part of page is stored in memory.
-> saves the output of page processing and reuses the output instead of re-processing the page when a user requests the page again.
-> Output cache enables you to store rendered HTML. The stored HTML is served in response to subsequent requests for the same page. We        can use output caching to cache the whole page or just the output of an ASP.NET control.

Leave a Reply

Your email address will not be published. Required fields are marked *