
372
|
Chapter 17: The HttpResponse Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
</head>
<body>
<form runat="server">
<asp:label id="Message" runat="server"/>
<asp:button id="Button1" text="Change Key 1"
onClick="Button1_Click" runat="server"/>
<asp:button id="Button2" text="Change Key 2"
onClick="Button2_Click" runat="server"/>
</form>
</body>
</html>
Notes
The AddCacheItemDependencies method is useful when you want to output
cache a page, but the page depends on the value of several items stored in the
ASP.NET cache. Rather than caching the page with a very short duration to avoid
stale data, you can use AddCacheItemDependencies to automatically invalidate
the output cache when the dependencies change.
AddCacheItemDependency
Response.AddCacheItemDependency(ByVal cacheKey As String)
Adds a cache item key to the list of cache keys upon which the output cache of the
current response depends. If the cache item identified by the key is modified, the
output cache of the current response will be invalidated and a fresh response will
be generated.
Parameter
cacheKey
A String containing the cache item key to add.
Example
The example shows how you can use the AddCacheItemDependency method to
set a cache key as a dependency for the output cache of the current response. If
the cache item represented by this key is modified, the output cache ...