3

I'm trying to do something similar to this question, I have a multitenant application and want to configure the output cache to be per tenant. However I'd rather not have to use a custom OutputCacheAttribute or have an OutputCache profile and remember to use this everywhere.

Is it possible to change the default OutputCache profile settings, adding the host to the VaryByHeader attribute?

Community
  • 1
  • 1
Luke Smith
  • 23,504
  • 8
  • 29
  • 28

1 Answers1

0

It is possible if you're using IIS7.X. I'm not sure if this will work for an MVC project.

Basically all you have to do is add this to your system.webserver section in the web.config file:

<caching>
    <profiles>
        <add extension=".aspx" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="00:00:05" varyByHeaders="host" />
    </profiles>
</caching>

If you have access to IIS then you can click on the "output cache" icon under your site and configure with the GUI but all it will do is update your web.config to something liek the above code.

nerdybeardo
  • 4,655
  • 23
  • 32