MichaCo / CacheManager

CacheManager is an open source caching abstraction layer for .NET written in C#. It supports various cache providers and implements many advanced features.
http://cachemanager.michaco.net
Apache License 2.0
2.34k stars 457 forks source link

Questions about clearing cached web outputs #217

Closed Jogai closed 6 years ago

Jogai commented 6 years ago

Is there some delay before a controller action output cache is really invalidated after calling cache.Clear();

And is it possible to target clearing outputcaches more specifically. For example per outputCacheProfile, or even better in my case, per host (in a multi tenant set up).

MichaCo commented 6 years ago

The old asp.net outputcache stuff is pretty limited in regards what you can do. No, there is no way to do anything profile specific. If you need more flexibility, I'd suggest to not use outputcache at all. Or, you can also write your own output cache provider (you can use the code of this one as template...) and play with it/customize it

Jogai commented 6 years ago

Ok thanks for the answer. I use mvcdonutcaching to make it a bit more useful. The cachemanager is set as the cache provider. That way I can clear the output cache trough the cache.Clear() method. But I do see some delay before I see the output cache actually cleared.

Config to make it work together for the curious:

<caching>
  <outputCache defaultProvider="CacheManagerOutputCacheProvider">
    <providers>
      <add cacheName="websiteCache" name="CacheManagerOutputCacheProvider"
           type="CacheManager.Web.CacheManagerOutputCacheProvider, CacheManager.Web" />
    </providers>
  </outputCache>
  <outputCacheSettings>
    <outputCacheProfiles>
      <add name="Indexes" duration="1" varyByParam="*" varyByHeader="host" />
    </outputCacheProfiles>
  </outputCacheSettings>
</caching>