
Configuring the Web Page for Caching
In this part of the walkthrough, you will configure the page for SQL cache dependency based on the Employees table of the Northwind database.
To configure the Web page for caching
-
Switch to Source view.
-
At the top of the page, add the following directive to indicate the dependency:
|
<%@ OutputCache Duration="3600" SqlDependency="Northwind:Employees" VaryByParam="none" %> |
The VaryByParam attribute indicates whether ASP.NET should take into consideration page parameters (such as query string or posted values) when caching. When VaryByParam is set to none, no parameters will be considered; all users are sent the same page no matter what additional parameters are supplied. Setting VaryByParam to * (an asterisk) means that for each unique combination of request parameters a unique page will be cached. However, setting VaryByParam to * can cause many different versions of the page to be cached, so if you know the parameters to vary caching by, it is recommended that you explicitly specify them in the VaryByParam attribute. For details, see Caching Multiple Versions of a Page.