Define Caching in ASP.NET.
- Caching technique allows to store/cache page output or application data on the client.
- The cached information is used to serve subsequent requests that avoid the overhead of recreating the same information.
There are several types of caching in ASP.NET:1. Page Output Caching
2. Page Fragment Caching
3. Data Caching
- This enhances performance when the same information is requested many times by the user.
1.
Page Output Caching: - It is implemented by placing an OutputCache directive at the top of the .aspx page at design time.
Example:<%@OutputCacheDuration="30" VaryByParam= "empId"%>
- In the above example, 'Duration' parameter specifies for how long the page would be in the cache and the 'VaryByParam' parameter is used to cache different version of the page.
2.
Data Caching:- It is implemented by using the Cache object to store and quick retrieval of application data.
3.
Page Fragment Caching:- It is used to store part of a Web form response in memory by caching a user control.