Chapter 6. Data and Output Caching


6. Data and Output Caching

Caching is the act of storing something for later retrieval, and in the Web world it is used to improve performance. There are many factors that affect the performance of Web sites, and two of these are the processing of ASP.NET pages and fetching data from databases. Once a Web site has been launched, the pages themselves generally stay fairly static, with only data changing, and even then that doesn't always change frequently. Fetching data from a database is relatively slow and uses resources (process, memory, etc.), so if that usage can be minimized, performance can be improved. Likewise, if a page doesn't change, why process it on every request?

Both of these problems can be solved with cachingstoring data so that it doesn't have to be processed or fetched. The performance impact of reducing resource usage may not be noticeable on small sites, but for larger sites with many users you can achieve dramatic improvements. In this chapter we're going to look at various caching schemes and how they can be used to improve performance. In particular, we will cover the following topics:

  • Using the application, session, HttpContext, and viewstate to store data

  • How to use output caching to reduce processing overhead

  • How to cache data to reduce SQL Server resource usage

  • How to use cache notifications so that stale data is never shown

  • How to use the cache API

Some of these techniques are simple, while others require a little more thought. All of them, however, are easy to code.



ASP. NET 2.0 Illustrated
ASP.NET 2.0 Illustrated
ISBN: 0321418344
EAN: 2147483647
Year: 2006
Pages: 147

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net