HttpResponse.AddCacheItemDependencies Method (ArrayList)
Assembly: System.Web (in system.web.dll)
public void AddCacheItemDependencies ( ArrayList cacheKeys )
public function AddCacheItemDependencies ( cacheKeys : ArrayList )
Parameters
- cacheKeys
The ArrayList containing the keys of the items that the current cached response is dependent upon.
The following code example demonstrates using an ASP.NET page that is output cached. The code for the page creates an ArrayList object of keys that are associated with items that are stored in the Cache object. Next, the code passes the ArrayList as the parameter in a call to the AddCacheItemDependencies method. This makes the output cached response not valid, if any of the files specified in the ArrayList change.
<%@ Page Language="VJ#" %>
<%@ outputcache duration="30" varybyparam="none" %>
<%@ Import namespace="Samples.AspNet.JSL" %>
<script runat="Server">
private void Page_Load(Object sender, System.EventArgs e)
{
// Create an array list that
// contains the keys for two
// items stored in the Cache object.
ArrayList deps = new ArrayList();
deps.Add("bookData");
deps.Add("authorData");
// Make the page invalid if either of the
// cached items change or expire.
get_Response().AddCacheItemDependencies(deps);
// Populate the DataGrids.
dgAuthors.set_DataSource(DataHelper.GetAuthorData());
dgAuthors.DataBind();
dgBooks.set_DataSource(DataHelper.GetBookData());
dgBooks.DataBind();
lblOutputCacheMsg.set_Text(System.Convert.ToString(DateTime.get_Now()));
} //Page_Load
</script>
<html>
<head>
<title>Cache Item Dependencies</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<table>
<tbody>
<tr>
<th style="WIDTH: 118px">
Authors</th>
<td>
<asp:DataGrid id="dgAuthors" runat="server"></asp:DataGrid>
</td>
</tr>
<tr>
<th style="WIDTH: 118px">
Books</th>
<td>
<asp:DataGrid id="dgBooks" runat="server"></asp:DataGrid>
</td>
</tr>
<tr>
<td style="WIDTH: 118px">
The page was generated at:</td>
<td>
<asp:Label id="lblOutputCacheMsg" runat="server"></asp:Label>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.