JavaScript EditorJavascript debugger     Javascript examples


Team LiB
Previous Section Next Section

Understanding Caching

Caching is the process of temporarily storing expensive resources in memory. These resources might be expensive because of the amount of processor time necessary to render them, because they reside on disk, or because they reside in a back-end database on another machine.

Pages that are expensive to render can consume so much processor time that the Web server becomes unable to fulfill requests in a timely fashion. Retrieving pages and other content from disk is much slower than serving them from memory, and this performance difference is magnified when the server needs to fulfill many requests simultaneously. Requests for large amounts of data from a back-end database often encounter both disk-based and network-based performance delays. (Thus, calls from one server to another can be substantially more expensive than fulfilling a request on the same machine.)

For these reasons, Web applications that need high performance have long used caching to mitigate the performance costs of expensive operations. The output from recent requests, or requested data, is cached in memory. Subsequent requests are served from this in-memory cache, rather than rendering a page or querying a database again. This can substantially improve the performance and scalability of an application. In the past, unfortunately, this improvement has come at a cost. Developers using classic ASP were limited to either using the intrinsic Session and Application objects for caching or rolling their own caching engines.

ASP.NET now offers a rich, robust framework for caching both page output and arbitrary data that developers can access easily using both declarative and programmatic means. ASP.NET output caching allows developers to declaratively cache page and user control output to avoid wasting resources by repeatedly rendering content that does not need to change from request to request. The cache API provides a number of methods that allow developers to add items to the cache, remove items from the cache, and set properties that determine the lifetime of items stored in the cache.


Team LiB
Previous Section Next Section


JavaScript EditorJavascript debugger     Javascript examples