Output cache ASP.NET with parameters

To improving performance to your web site you can add output cache to your web pages. If you dynamic pages you can use dynamic output cache by adding VaryByParam. The attributes Duration and VaryByParam are required when you output cache ASP.NET pages.

Main idea:
<%@ OutputCache Duration="Seconds" VaryByParam="QueryStringParamName"%>

Step 1: Put this line of code above the Page directive. In this example the parameter name is id.

<%@ OutputCache Duration="60" VaryByParam="id"%>

<%@ Page

Step 2: If you do not have a parameter set the value to none.

<%@ OutputCache Duration="60" VaryByParam="none"%>

<%@ Page



outputcache varybyparam duration cache