Crystal clear :
Step 1
Create a webrole with a few websites with a default.aspx file and a plain regular <%@ OutputCache Duration="3600" VaryByParam="*" %>, in the webconfig use the appfabric cache provider for outputcache and link to your cache subscription in azure with provided code
Use only one instance of the webrole, lauch the page, it chaches it, reload few times, it works solid
Step 2
Now increase to 2 or more instances of this WebRole
Here is my problem, reload your default.aspx page on client, now depending of the Webrole the loadbalancer will direct your request, you might get a System.Web.Caching.CacheDependency error upon the fact that the default.aspx cached in distributed cache seems to be based on a file monitoring dependancy, a hard path of the default.aspx page like "E:\sitesroot\2\". But you may have (and you do) "F:\sitesroot\2\" on the other instances of the Webrole.
So it fires an error :
System.Web.HttpException (0x80070003): Directory 'E:\sitesroot\2' does not exist. Failed to start monitoring file changes.
at System.Web.FileChangesMonitor.FindDirectoryMonitor(String dir, Boolean addIfNotFound, Boolean throwOnError)
at System.Web.FileChangesMonitor.StartMonitoringPath(String alias, FileChangeEventHandler callback, FileAttributesData& fad)
at System.Web.Caching.CacheDependency.Init(Boolean isPublic, String[] filenamesArg, String[] cachekeysArg, CacheDependency dependency, DateTime utcStart)
at System.Web.Caching.CacheDependency..ctor(Int32 dummy, String[] filenames)
at System.Web.Caching.OutputCache.HasDependencyChanged(Boolean isFragment, String depKey, String[] fileDeps, String kernelKey, String oceKey, String providerName)
at System.Web.Caching.OutputCache.Get(String key)
at System.Web.Caching.OutputCacheModule.OnEnter(Object source, EventArgs eventArgs)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I'm struggling with this errors since one week, i don't get it, if anyone knows a way for implementing distributed outputcache over multiple instances of webroles please share your solution.
EDIT
I ended dropping completely asp.net outputcache provider for appfabric and writing a custom cache with appfabric. Works great, few line of codes and cachedependancy on azure made easy.
I ended dropping completely asp.net outputcache provider for appfabric and writing a custom cache with appfabric. Works great, few line of codes and cachedependancy on azure made easy.