3

I have an MVC web project and I am trying to setup OutputCache for some of the pages using redis cache running locally, eventually to be hosted in azure.

I have decorated my ActionResult with

[OutputCache(CacheProfile = "cacheprofile1")]

and have the following in my web.config under system.web / caching

  <outputCacheSettings>
    <outputCacheProfiles>
      <add name="cacheprofile1" duration="1800" varyByParam="none"/>
    </outputCacheProfiles>
  </outputCacheSettings>

My Cache provider is set accordingly

     <outputCache defaultProvider="localRedisOutputCache">
        <providers>
          <add name="localRedisOutputCache" type="Microsoft.Web.Redis.RedisOutputCacheProvider" host="127.0.0.1" accessKey="" ssl="false" />
        </providers>
      </outputCache>

No entries are being made into my cache. If I change my ActionResult decoration to

[OutputCache(Duration=1800)]

it works, but I'd rather not have to set this manually against each method.

Any ideas on why the cache profile is being ignored and how to resolve would be appreciated.

Raghavendra
  • 1,419
  • 4
  • 19
  • 28
robsta
  • 416
  • 5
  • 18

0 Answers0