Caching means programmed memory area. To improve the performance of our application or program we perform caching process. We have many places where caching is implicitly performed. There are 3 important type of caching in ASP.NET and three types should be explicitly performed by user. These three types are:
(i) Page output caching
(ii) Data caching
(iii) Fragment caching
Based on different requirements user can select any type and all these types provide different results.
(i) Page output caching: In this type of caching we store entire page processed result in cache memory. The results are cached for a specific duration which is provided by user.
(ii) Data caching: Data caching is a collection of in memory objects. It gets automatically deallocated based on memory limitation, time limit and few other essential dependencies. It is also termed as application data caching because the scope of these in memory objects are at the application level. In ASP.NET web based context, this cache object exists for the entire web application, can be shared across the user sessions and web requests.
(iii) Fragment caching: However, there will be situations where we would like to cache only sections of page rather than the whole page. There may be sections of the page where the information gets updated every second or so and these sections should not cached.
This can be implemented in ASP.NET using Fragment Caching. Fragment Caching is the technique by which we can cache a sections of the page instead of caching the whole page.
This is accomplished by dividing the pages into usercontrols and caching the individual usercontrols. Say we have a page which has 5 sections. We can split the static sections into user controls and cache them such that only that portion of the page is cached.