ASP.NET MVC命中的OutputCache的每一个动作 [英] ASP.NET MVC hits outputcache for every action

查看:129
本文介绍了ASP.NET MVC命中的OutputCache的每一个动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在运行一个相当大的网站的ASP.NET MVC 3和建设的AppFabric作为分布式缓存解决方案。我们已经实现了自定义OutputCacheAdapter使用我们的AppFabric集群。

We are running quite a large site build with ASP.NET MVC 3 and AppFabric as a distributed caching solution. We have implemented a custom OutputCacheAdapter to use our AppFabric cluster.

我们看到了ASP.NET要求每一个动作的OutputCacheProvider.Get()方法,即使该行为不与@OutputCacheAttribute装饰。

We are seeing that ASP.NET calls the OutputCacheProvider.Get() method for every action, even if that action is NOT decorated with a @OutputCacheAttribute.

这是没有太大的问题,如果你使用默认的outputcacheprovider但是当你正在运行驻留在单独的机器的outputcacheprovider它。

That isn't much of a problem if you use the default outputcacheprovider but it is when you are running an outputcacheprovider that resides on seperate machines.

推荐答案

这是该输出缓存首先检查该页面的缓存副本设计。如果有一个缓存副本,它回来了,没有什么可以再被执行。特别是,没有控制器和无控制器动作导出,检查或执行。出现这种情况只有在页面没有被缓存。

It is by design that the the output cache is checked first for a cached copy of the page. If there is a cached copy, it's returned and nothing further is executed. In particular, no controller and no controller action is derived, inspected or executed. This happens only if the page is not cached.

您将需要更改缓存provider,使其可以迅速判断一个网页可能会被缓存。只有当它是一个可缓存的页面,那么就应该去检查分布式缓存。这个检查不能根据 OutputCacheAttribute ,因为它们不是请求处理的这部分中可用。相反,快速检查必须与URL时,cookies和其他HTML头信息进行。

You will need to change your cache provider so that it can quickly determine if a page can potentially be cached. Only if it is a cachable page, then it should go and check the distributed cache. This check cannot based on the OutputCacheAttribute as they are not available during this part of the request processing. Instead, the quick check must be made with the URL, the cookies and other HTML header information.

这篇关于ASP.NET MVC命中的OutputCache的每一个动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆