In the first part of this series we looked into Output Caching. In this part, we will see the options available with partial page caching. Just like output caching you can cache specific sections of a web page using partial page caching. This is achieved by caching user controls used for building the ASP.NET page.
User Controls are typically designed to be shared across multiple pages to enable reuse of their functionality. To achieve partial page caching, you can use the @OutputCache directive : using its default attributes will enable to cache the user control on a per page basis. By setting the Shared = “true” attribute, you can share the user controls among multiple pages. This leads to memory savings on the server, especially if your web site is made up of large number of pages (it always is, isn’t it ?:))
<%@ OutputCache Duration=”30” VaryByParam=”*” Shared=”true” %>
The above directive tells the .NET framework that a copy of the user control is cache and shared amongst all the pages using it for 30 seconds and to vary the cache by any and all parameters