Asked By shweta chandaliya
02-Feb-10 07:49 AM

Our application is deployed in the web farm. Web farm has 2 servers. We need to synchronize the cache objects between these 2 server. For this, I am using a cache dependency on a text file, like below;
Cache.Insert("articlespostHashtable", articledata.PostHashtable, new System.Web.Caching.CacheDependency(Server.MapPath(depFileName)), System.Web.Caching.Cache.NoAbsoluteExpiration,
System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, null);
And whenever the data is updated, I modify the text file so that my cache is invalidated.
using (StreamWriter sw = new StreamWriter(Server.MapPath(ConfigurationManager.AppSettings["CacheSynchDepFile"].ToString()), true))
{
sw.Write(DateTime.Now.ToString() ;
}
The text file i am storing on a shared folder which is on the server1. The other server Server2 also has the access to this file through the shared folder.
This thing is working properly if the data is updated on the Server1 but not working properly if the data is getting updated from Server2. It do not refreshes the data immediatly and takes few minutes. Please guide me for the same.