Using the Page Output Cache

Page output caching is the method of caching the output of an entire page. After the page is rendered and cached, all subsequent requests for the page are served from the memory resident version until it is removed—taken out of the cache.

Page output caching can be done in two ways. The first uses the @OutputCache directive (seen in Listing 16.1), and the second uses the HttpCachePolicy class. Essentially, they accomplish the same thing, but by using the @OutputCache directive, you are accessing the HttpCachePolicy class through a higher-level, user-friendly wrapper.

In this section, I will discuss how to use both methods to enable page output caching. I will review their properties that enable you to vary the way ...

Get Programming Data-Driven Web Applications with ASP.NET 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.