Chapter 17. Caching and Performance

There are several ways to achieve higher performance and better scalability in ASP.NET. One way is through the use of caching. Caching is a technique whereby frequently requested data is stored in memory so that the next time the same information is requested, it can be fetched from memory rather than generated by the application.

This can result in a significant performance boost, especially for dynamically generated content (such as ASP.NET web pages and components) and in cases where the data underlying the response is expensive to gather (such as database queries).

Most web browsers cache pages they receive, so if the same page is requested again, it does not have to be sent over the Internet, but rather is retrieved directly from the local hard drive. Most operating systems also employ caching of some sort to store frequently requested data in memory, rather than requiring additional hard-drive reads. The only caching this chapter is concerned with is server-side caching performed by the .NET Framework.

In some respects, caching is similar to the storage of state objects. (See Chapter 6 for a complete discussion of state in ASP.NET.) In both cases, data is saved for use across multiple requests, and in the case of application state, across multiple sessions. However, don’t be misled by this apparent similarity. With state objects, the developer explicitly saves a particular piece of data in a particular place, intending to retrieve that piece ...

Get Programming ASP.NET 3.5, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.