HttpResponse.AddCacheItemDependency Method

Makes the validity of a cached response dependent on another item in the cache.

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)

member AddCacheItemDependency : 
        cacheKey:string -> unit

Parameters

cacheKey
Type: System.String

The key of the item that the cached response is dependent upon.

When the item corresponding to the cacheKey parameter is removed from the cache, the cached response of the current item is invalid.

TopicLocation
How to: Cache Versions of a Page Using HTTP HeadersBuilding ASP .NET Web Applications
How to: Set the Cacheability of an ASP.NET Page DeclarativelyBuilding ASP .NET Web Applications
How to: Set a Page's Cacheability ProgrammaticallyBuilding ASP .NET Web Applications
How to: Cache Page Output with File DependenciesBuilding ASP .NET Web Applications
How to: Cache Versions of a Page Using Requesting BrowserBuilding ASP .NET Web Applications
How to: Set Expiration Values for ASP.NET Page CachingBuilding ASP .NET Web Applications
How to: Cache Page Output with Cache Key DependenciesBuilding ASP .NET Web Applications
How to: Retrieve Values of Cached ItemsBuilding ASP .NET Web Applications
How to: Cache Versions of a Page Using HTTP HeadersBuilding ASP .NET Web Applications
How to: Set the Cacheability of an ASP.NET Page DeclarativelyBuilding ASP .NET Web Applications
How to: Set a Page's Cacheability ProgrammaticallyBuilding ASP .NET Web Applications
How to: Cache Page Output with File DependenciesBuilding ASP .NET Web Applications
How to: Cache Versions of a Page Using Requesting BrowserBuilding ASP .NET Web Applications
How to: Set Expiration Values for ASP.NET Page CachingBuilding ASP .NET Web Applications
How to: Cache Page Output with Cache Key DependenciesBuilding ASP .NET Web Applications
How to: Retrieve Values of Cached ItemsBuilding ASP .NET Web Applications

The following example is an ASP.NET user control that is output cached. The code for the control calls the AddCacheItemDependency method with the key of an item stored in the Cache object passed as its parameter. If the item does not exist in the cache, the control's response that was stored in the output cache is invalidated. This means that on the subsequent request, a new version of the control's response will be added to the output cache.

Next, the code checks whether an item associated with a bookData key is stored in the Cache object, and displays one of two lines of text dependent upon the result. Then, the code sets the DataSource property of a DataGrid control, which is named dgBooks, with a call to a custom DataHelper class's shared GetBookData method, and populates the DataGrid with the DataBind method.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Reference

AddCacheItemDependency

Other Resources

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft