C# Microsoft MVC Preview 4 中的 OutputCacheFilter 是否真的节省了操作调用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10661/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does the OutputCacheFilter in the Microsoft MVC Preview 4 actually save on action invocations?
提问by CVertex
We deployed a live, fresh, swanky site using preview 3 including rigorous stress testing.
我们使用预览版 3 部署了一个实时、新鲜、时髦的网站,包括严格的压力测试。
Page Output caching was our saviour and afforded us the ability to meet our performance contractual requirements.
页面输出缓存是我们的救星,它使我们能够满足我们的性能合同要求。
My question is, is there a difference between action OutputCacheFilter
and page output caching?
我的问题是,动作OutputCacheFilter
和页面输出缓存之间有区别吗?
Is the action output caching faster than page output caching?
动作输出缓存是否比页面输出缓存更快?
采纳答案by Haacked
Internally, the OutputCacheAttribute (aka output cache filter) uses the same internal mechanism as page output caching(aka the @OutputCache directive).
在内部,OutputCacheAttribute(又名输出缓存过滤器)使用与页面输出缓存(又名@OutputCache 指令)相同的内部机制。
Therefore, it's not any faster than page output caching. However, with MVC, you really can't use page output caching via the @OutputCache directive in MVC because we render the view (aka page) afterthe action runs. So you would gain very little benefit.
因此,它并不比页面输出缓存快。但是,对于 MVC,您确实无法通过 MVC 中的 @OutputCache 指令使用页面输出缓存,因为我们在操作运行后呈现视图(又名页面)。所以你会获得很少的好处。
With the output cache filter, it does the correct thing and does not execute the action code if the result is in the output cache. Hope that helps. :)
使用输出缓存过滤器,它会做正确的事情,如果结果在输出缓存中,则不会执行操作代码。希望有帮助。:)
回答by Ricky
Just be aware that there currently is a bug if you call Html.RenderAction(..) on an Action that is marked to be cached. Instead of the specific action being cached, the entire page gets cached. I reported this on codeplex already and it seems to be a known issue: Calling <% HTML.RenderAction<...>(...); %> to an Action with [OutputCache(..)] causes entire page to cache.
请注意,如果您在标记为缓存的 Action 上调用 Html.RenderAction(..) ,则当前存在一个错误。不是缓存特定操作,而是缓存整个页面。我已经在 codeplex 上报告了这个问题,这似乎是一个已知问题: Calling <% HTML.RenderAction<...>(...); %> 到带有 [OutputCache(..)] 的操作会导致整个页面缓存。