Use Page or Fragment Caching

Problem

You want to increase performance by caching completely rendered pages.

Solution

Add the OutputCache directive to a page or a user control, and specify how long the page should be kept in the cache.

Discussion

A modest use of caching can reduce bottlenecks such as database access and dramatically increase a Web site’s overall performance. Caching has the greatest effect in a highly trafficked site. For example, consider what happens if you cache a page that displays the results of a database query. If you cache this page for one minute and ten requests are received for the page over that oneminute period, you’ll reduce the database overhead by a factor of 10.

Implementing caching is easy. You simply add an OutputCache ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook 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.