title: How to invalidate ASP.NET cache if data changes in PostgreSql database
body: <p>ASP.NET/MONO MVC2 application standard ASP.NET Web cache is used to speed up database access:</p>
  
  <pre><code>string GetName() {
    // todo: dedect if data has changed and invalidate cache
    var name = (string)HttpContext.Current.Cache["Name"];
    if (name!=null)
      return name;
    name = db.Query("SELECT name from mydata");
    HttpContext.Current.Cache.Insert("Name", name);
    return name;
  }
  </code></pre>
  
  <p>mydata can changed by other application.
  In this case this method returns wrong data.
  How to detect if data is changed and return fresh data from PostgreSql database in this case ?</p>
  
  <p>It is OK to clear whole Web cache if mydata has changed.</p>