I have a user control which makes a System.Net.Webrequest to get weather data
from a rather low-performance XML feed. It times out peridically, which puts
a blank page in the cache until the next time the cache expires. I figure
there has to be an easy way to detect whether I got data from the XML feed,
and if not, keep the previously cached (though somewhat outdated) older data
until such time as the XML source is responding again. Currently, I am
implementing the caching via a directive in the ascx file:
<%@ OutputCache Duration="600" VaryByParam="none" %>
Can I get the desired behavior by simply changing parameters here, or do I
have to implement caching programmatically instead, or ???
Venkat_KL - 07 Oct 2005 07:05 GMT
Dear Andy_S,
You can use Cache Dependency for your problem.
ASP.NET allows you to define the validity of a cached item, based on an
external file, a directory, or another cached item.
These are called file dependencies and key dependencies.
If a dependency changes, the cached item is invalidated and removed from
the Cache. You can use this technique to remove items from the Cache when
their data source changes. For example, if you write an application that
processes financial data from an XML file and renders it in a graph, you can
insert the data from the file in the Cache and maintain a dependency on that
XML file. When the file is updated, the item is removed from the cache, your
application rereads the file, and a new version of the item is inserted.
Note The Cache has no information about the content of the items it
contains. It merely holds a reference to those objects. It also provides
methods to track their dependencies and set expiration policies.
go through these links
INFO: ASP.NET Caching Overview
=====================
http://support.microsoft.com/kb/307225/EN-US/
Caching Application Data
===============
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
concacheapis.asp
CacheDependency Class
==============
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fSystemWebCachingCacheDependencyClassTopic.asp
CacheDependency Members
=================
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fsystemwebcachingcachedependencymemberstopic.asp
bye
Venkat_KL