0

I have implemented OutputCache in an application and it works fine, but since I have specified the location as server, and the applications runs in server farm (2 servers) , when I clear the cache, it clears only from one server at one time. I have thought about specifying a server location (hardcode), so that the cache will be stored at one place and can be easily cleared when I have to. So, is there any way to hardcode server name for the location attribute in OutputCache? Or from webconfig file?

Declaration in webconfig

<system.web>
<caching>
  <outputCacheSettings>
    <outputCacheProfiles>
      <add name="Cache10Minutes"
           duration="300"
           location="Server"
           varyByParam="none"/>
    </outputCacheProfiles>
  </outputCacheSettings>
</caching>

Definition in related page (page header)

<%@ OutputCache CacheProfile="Cache10Minutes" Duration="300" Location="Server" VaryByParam="none"%>

To clear cache on button click

HttpRuntime.UnloadAppDomain()

Or what about creating a trigger from database on update from client. Can this clear cache from both the servers? Correct me if my idea is wrong or not clear enough, I'm confused. Please advice.

Tipsy
  • 68
  • 6

1 Answers1

1

As far as I know output cache is per server only. You can implement your own OutputCacheProvider however and implement your own caching mechanism: OutputCacheProvider Class, MSDN

OutputCacheProvider for Redis

Or maybe use distributed cache with AppFabric: How to: Configure the AppFabric Output Cache Provider for ASP.NET . Be aware though that Microsoft is ending support for AppFabric for Windows Server next year Microsoft AppFabric 1.1 for Windows Server Ends Support 4/2/2016

BunkerMentality
  • 1,327
  • 16
  • 21
  • How about creating a web service(.dll) file to perform cache clearing in both servers once called by the application running on current server. – Tipsy Apr 27 '15 at 07:04