Using Fragment Caching

So far, you have seen how to enable caching for entire pages. You might be thinking, “This is all well and good, but I make money off advertising. I can't have my ad banners cached because they are rotating banners and need to change on every request.” Perhaps your site serves some dynamic content that must be refreshed on every request—for instance an up-to-the-minute news flash.

You are in luck because, in this section, we will be discussing fragment caching, the technique of caching the output of portions of pages, rather than complete documents. It might sound complicated, but it is very easy.

You can take advantage of fragment caching by including one or more cache-enabled user controls within your web form. For example, ...

Get Programming Data-Driven Web Applications with ASP.NET now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.