Output Caching

The easiest way to implement caching in your ASP.NET web applications is through directives at either the page or the user control level. Unfortunately, this method is also the most limiting and frustrating to work with.

@OutputCache Directive

The basis for output caching at both the page and the user control level is the @OutputCache directive. Although you can use many different possible attributes (a few of which you’ll see in a bit), two are mandatory: Duration and VaryByParam.VaryByControl can be substituted for VaryByParam in user controls, however.

Duration Attribute

The Duration attribute is fairly straightforward, but you must realize that the number it accepts is the number of “seconds” that you want your content to be cached ...

Get Debugging 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.