ViewEngine 上的输出缓存问题,为 1 个控制器使用 2 个单独的视图

发布于 2024-08-20 14:18:12 字数 391 浏览 15 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

任谁 2024-08-27 14:18:12

您的问题是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文