开发者

Is it possible to modify the default outputcache settings

开发者 https://www.devze.com 2023-01-15 13:00 出处:网络
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 OutputCache

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 u开发者_StackOverflow社区se this everywhere.

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消