ASP.NET

Application Data Caching

This tutorial covers ASP.NET's built-in data caching features. Caching is a long-standing means of improving the performance of any software system. The idea is to place frequently used data in quickly accessed media. Even though access times for mass storage continue to improve, accessing data from a standard hard disk is much slower than accessing it in memory.

By taking often-used data and making it available quickly, you can improve the performance of your application dramatically.

After completing this tutorial, you will be able to

  • Improve the performance of your application by using the application cache
  • Avoid unnecessary round-trips to the database
  • Manage items in the cache

The ASP.NET runtime includes a dictionary (key-value map) of CLR objects. The map (named Cache) lives with the application and is available via the HttpContext and System.Web.UI.Page. Using the cache is very much like using the Session object. You may access items in the cache using an indexer. In addition, you may control the lifetime of objects in the cache and even set up links between the cached objects and their physical data sources. Let's start by examining a case in which using the cache is justified.