One of the most interesting changes in the Whidbey's Cache object is that it now supports custom types of cache dependencies. In brief, a cache dependency represents a logical dependency between a cached item and a file(s), folder(s), or another cached item(s). When the dependency is broken (i.e., the file/folder/item changes), the bound cached item is removed from the cache.
CacheDependency dep = new CacheDependency(fileName, dateTime);
cache.Insert(key, value, dep);
In ASP.NET 1.1, the CacheDependency class is sealed and cannot be inherited to create custom classes. In ASP.NET 2.0 this is going to change. The benefit is that you can now extend the range of sensitive objects and use your own objects in addition to files, folders, and other cached items.
The most common type of custom dependency is a dependency set on a database table. For example, you run a query, store the results in a DataSet and place the DataSet into the Cache. Next, whenever the contents of the table changes the ASP.NET Cache automatically invalidates the entry meaning that it is time for you to refresh the data. This functionality, though, will be provided as a standalone class named SqlCacheDependency. It is worth noticing that this class works only with SQL Server 7.0 and newer and that the behavior changes significantly if you use SQL Server Yukon. (You can get a finer control over the changes in this case.)