简体   繁体   English

具有显示模式的mvc输出缓存

[英]mvc output cache with display modes

I have a mvc4 web site with nuget package Install-Package jQuery.Mobile.MVC the code for home is : 我有一个带有nuget包Install-Package jQuery.Mobile.MVC的mvc4网站,家庭代码为:

[OutputCache(CacheProfile = "SiteCache", VaryByParam = "none")]
public ActionResult Index()
{
    return View();
}

I see a problem where sometimes I go from desktop browser and get a layout of mobile. 我看到一个问题,有时我会从桌面浏览器转到移动设备的布局。 could it be that a user entered from mobile and the IIS cached for the mobile page and it getting served for users after it as mobile layout ? 难道是用户从移动设备输入的,而IIS为移动设备页面缓存了,并且在它作为移动设备布局后得到了服务?

Yes, the problem is that someone with mobile accessed the site before you. 是的,问题是有人使用移动设备访问了您之前的站点。 It caches the Action/View in IIS for everybody else. 它为其他所有人在IIS中缓存操作/视图。 It's server cache, not client. 它是服务器缓存,而不是客户端。 You could use a Guid param, and cache for it, for the client session to cache the index for every client connected. 您可以使用Guid参数并为其缓存,以便在客户端会话中为每个连接的客户端缓存索引。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM