---
title: "Caching in asp.net"  
description: "Caching is a technique widely used in computing to increase performance by keeping frequently accessed or expensive data in memory. In context of web"  
author: "Amit Singh"  
published: 2010-11-06  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/43/caching-in-asp-dot-net  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# Caching in asp.net

Caching is a [technique](https://answers.mindstick.com/qa/93922/why-c-sharp-programmers-use-properties-technique-in-c-sharp-programming) widely used in [computing](https://www.mindstick.com/blog/23070/how-to-get-a-career-in-computing) to increase performance by keeping frequently accessed or [expensive](https://www.mindstick.com/interview/94/why-can-a-group-by-or-order-by-clause-be-expensive-to-process) data in memory. In context of [web application](https://www.mindstick.com/articles/13069/progressive-web-application-pwas-all-you-need-to-know-about), caching is used to retain the pages or data across [HTTP requests](https://www.mindstick.com/articles/1406/debugging-http-requests-and-http-response) and reuse them without the expense of recreating them.ASP.NET has 3 kinds of [caching strategies](https://www.mindstick.com/forum/161237/what-are-some-common-caching-strategies)\

[Output Caching](https://answers.mindstick.com/qa/51751/what-is-output-caching-in-web-application), [Fragment Caching](https://www.mindstick.com/interview/959/what-is-fragment-caching-in-asp-dot-net), Data Caching \
**CachingOutput Caching:** Caches the dynamic output generated by a request. Some times it is useful to cache the output of a website even for a minute, which will result in a better performance. For caching the whole page the page should have OutputCache directive.<%@ OutputCache Duration="60" VaryByParam="state" %>\
**Fragment Caching:** Caches the portion of the page generated by the request. Some times it is not practical to cache the entire page, in such cases we can cache a portion of page<%@ OutputCache Duration="120" VaryByParam="CategoryID;SelectedID"%>\
**Data Caching:** Caches the objects programmatically. For data caching asp.net provides a cache object. \
For e.g.: cache ["States"] = dsStates;\

---

Original Source: https://www.mindstick.com/blog/43/caching-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
