ViewEngine 上的输出缓存问题,为 1 个控制器使用 2 个单独的视图
http://www.hanselman.com/blog/MixMobileWebSitesWithASPNETMVCAndTheMobileBrowserDefinitionFile.aspx
简单起见,请尝试一下。基本上,我正在尝试做移动视图引擎,但后来我发现我有outputcache,它将缓存2个视图之一(PC视图),然后当我尝试通过移动设备访问时,它会自动显示PC视图。
那么有没有办法在保留输出缓存的同时避免这个问题呢?
谢谢
http://www.hanselman.com/blog/MixMobileWebSitesWithASPNETMVCAndTheMobileBrowserDefinitionFile.aspx
To the sake of simplicity, please try out this. Basically, I am trying to do the mobile view engine, but then i found out that I have outputcache, which will cache one of 2 view (PC view) and then when i tried to access through mobile, it automatic show PC view.
So is there anyway to avoid this problem while still keeping the outputcache?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题是 Outputcache 的开箱即用差异(varibyparam、varybycostum、varybyquerystring)还不够吗?
如果您需要一个因某些路由值而存在差异的缓存,那么这可能会对您有所帮助。
http://blog.stevensanderson.com /2008/10/15/partial-output-caching-in-aspnet-mvc/
或这个:
http://blog.maartenballiauw。 be/post/2008/06/Creating-an-ASPNET-MVC-OutputCache-ActionFilterAttribute.aspx
我还没有尝试过这些解决方案,但也许它们可以帮助您入门。
编辑
在我写这个答案时,我认为 Outputcache 没有路由值的变化。但它确实有。每个 URL 都有自己的缓存条目。
Is your problem that out of the box variance from Outputcache (varibyparam, varybycostum, varybyquerystring) is not enough?
If you need a cache that has variance by some route value then this might help you.
http://blog.stevensanderson.com/2008/10/15/partial-output-caching-in-aspnet-mvc/
or this:
http://blog.maartenballiauw.be/post/2008/06/Creating-an-ASPNET-MVC-OutputCache-ActionFilterAttribute.aspx
I havn't tried these solutions but maybe they get you started.
EDIT
At the time I wrote this answer I thought that Outputcache has no varinace by route values. But it realy has. Each URL has its own cache entry.