Nothing really to say here, I just wanted to force an update to my blog so that a HttpCacheDependency class (derived from Whidbey's CacheDependency class) had something to check for updates to trigger a cache expiry (update: It worked, code attached).

public class HttpCacheDependency : System.Web.Caching.CacheDependency
{
    private string m_ContentOnFile;
    private string m_Url;
    public HttpCacheDependency(string url)
    {
        this.m_Url = url;
        this.m_ContentOnFile = this.GetContent(url);

        TimerCallback callback = new TimerCallback(this.m_Timer_Callback);
        this.m_Timer = new Timer(
callback, null, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1));
    }

    private Timer m_Timer;
    private void m_Timer_Callback(object obj)
    {
        string newContent = this.GetContent(this.m_Url);
   
        if (this.m_ContentOnFile != newContent)
        {
            this.m_ContentOnFile = newContent;
            this.NotifyDependencyChanged(this, new EventArgs());
        }
    }

    private string GetContent(string url)
    {
        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url
);
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        StreamReader reader = new StreamReader(response.GetResponseStream());
        string content = reader.ReadToEnd();

        return content;
    }
}

I can imagine that this would be useful for things like those web-based RSS feeders or other content aggregation services.