如何配置 MVC 配置文件以不进行缓存
我试图弄清楚如何将 ASP.NET MVC2 配置文件配置为完全没有缓存。我当前的配置文件有这个 xml 节点...
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="ZeroCacheProfile" duration="0" varyByParam="*" location="None" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
这向我表明,该应用程序没有进行缓存。我错过了什么吗?将继续浏览互联网寻找最简洁的答案。谢谢。
I am trying to figure out how to configure a ASP.NET MVC2 config file to have absolutely no caching. My current config file has this xml node...
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="ZeroCacheProfile" duration="0" varyByParam="*" location="None" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
That would indicate to me, that no caching is going on with with this application. Am I missing something? Will continue to browse the internet searching for the most succinct answer. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除了定义缓存配置文件之外,在 web.config 中定义缓存配置文件本身不会做任何有用的事情。必须有一些东西使用这个缓存配置文件,否则它仍然是一个简单的定义。这就是工作的一半。
后半部分是装饰您想要使用
[OutputCache]
属性:或者如果您想对站点的所有控制器执行此操作,请定义一个基本控制器,所有控制器都派生自该基本控制器,然后进行装饰这个基地具有上述属性的控制器。
Defining a cache profile in web.config per se doesn't do anything useful other than defining a cache profile. There must be something using this cache profile otherwise it stays a simple definition. So that's half of the job.
The second half is to decorate all your controllers or actions that you would like to disable caching for with the
[OutputCache]
attribute:or if you want to do this for all controllers of your site define a base controller that all your controllers derive from and then decorate this base controller with the aforementioned attribute.