sql cache dependency allows for cached data to be evicted and refreshed when it becomes stale. Basically ASP.NET checks for the changes in the datatable in sql server, if it finds one, it refreshes the cached data.
Polling based sql cache dependency is very easy to configure as follows :
open Visual Studio Command Prompt then execute the two lines below :
aspnet_regsql.exe -S "ServerName\InstanceName" -E -d "DataBaseName" -ed
aspnet_regsql.exe -S "ServerName\InstanceName" -E -d "DataBaseName" -et -t "DataBaseTable"
then add this to system.web section of your web.config file :
<caching>
<sqlCacheDependency enabled="true" pollTime="30000" >
<databases>
<add name="myDataBaseName"
connectionStringName="myConnectionStringName" />
</databases>
</sqlCacheDependency>
</caching>
then set the attributes of the datasource appropriately
<asp: SqlDataSource EnableCaching="true" CacheDuration="Infinite"
SqlCacheDependency="DatabaseName:TableName" />
You can also make the output cache sql dependent :
<%@ OutputCache Duration="999999" SqlDependency="DatabaseName:TableName"
VaryByParam="none" %>