热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何在IIS7.5上禁用服务器端缓存(aspnetmvc3)-Howtodisableserver-sidecachingonIIS7.5(aspnetmvc3)

ImstrugglingwithmyIISsetupregardingcaching,heresabriefdescriptionofmyproblem:我正在为关于

I'm struggling with my IIS setup regarding caching, here's a brief description of my problem:

我正在为关于缓存的IIS设置而烦恼,以下是我的问题的简要描述:

I'm making a site for mobile and non-mobile, sharing the same controllers. IE: mysite/page will serve either mysite/page.cshtml, or mysite/M/page.cshtml, depending on the device.

我正在制作一个移动和非移动的网站,共享相同的控制器。IE: mysite/page将为mysite/page提供服务。cshtml或mysite / M /页面。cshtml,取决于设备。

Here's the catch, it worked fine with my local and integration environment (cassiini and iis 6), but on another machine (2008r2/iis 7.5), apparently there is an aggressive server-side caching policy:

这里有一个问题,它在我的本地和集成环境(cassiini和iis 6)中工作得很好,但是在另一台机器(2008r2/iis 7.5)上,显然有一个积极的服务器端缓存策略:

  • If I access the website from a desktop machine, I have the correct pages (desktop version)
  • 如果我从桌面计算机访问网站,我就有正确的页面(桌面版本)
  • If now I use my mobile phone to access the site, I will have the desktop version, (which implies a server-side cache, my phone is not using the same network).
  • 如果现在我用手机访问网站,我将有桌面版本(这意味着服务器端缓存,我的手机没有使用相同的网络)。

On the contrary, if I were to restart the server and access the site using my phone first, then I will get the mobile version on my desktop (only for the pages I already visited of course).

相反,如果我重新启动服务器并首先使用我的手机访问站点,那么我将在我的桌面上获得移动版本(当然只针对我已经访问过的页面)。

I tried 2 solutions so far:

到目前为止,我尝试了两种解决方案:

Disabling OutputCache from my Web.config:

从我的网站上禁用OutputCache。


  [..]
  

And unchecking "Enable output cache" in "Output Caching" for my site in IIS.

在IIS中取消对我的站点的“输出缓存”中的“启用输出缓存”。

What's bugging me is that I do not have this problem with my other server (iis 6.0), although caching is enabled on this one, which leads me to think it is related to iis 7 caching addition.

困扰我的是,我的另一个服务器(iis 6.0)没有这个问题,尽管在这个服务器上启用了缓存,这使我认为它与iis 7缓存的添加有关。

My question is simple: how does one disable server-side caching on IIS 7.5?

我的问题很简单:如何在IIS 7.5上禁用服务器端缓存?

Thanks in advance for your iis lights!

提前谢谢你的iis灯!

Found it!

Sorry guys you could not really guess that one, I extend RazorViewEngine (actually I used a sample mobile mvc3 template app), and this class overrides FindView, it is supposed to take into account a useCache parameter, but apparently no matter how I configure IIS, it was set to true with iis7. I set it to false everywhere. I'll look into appropriate tuning of that parameter tomorrow.

对不起人你真的不能猜,我延长RazorViewEngine(实际上我使用一个移动mvc3模板示例应用程序),这类覆盖FindView,它应该考虑useCache参数,但显然无论我怎么配置IIS,它与iis7被设置为true。我把它设为false。我将在明天研究这个参数的适当调优。

public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)

Thanks for your help guys, I have a good understanding of all the caching possibilities with IIS now ;). It's interesting that this behaves differently with IIS 7.0 (IIS6 and Cassiini were consistent).

感谢您的帮助,我现在已经很好地理解了IIS的所有缓存可能性。有趣的是,IIS6和Cassiini在IIS 7.0中的表现是不同的。

Edit:

编辑:

More info: http://aspnet.codeplex.com/workitem/8201?PendingVoteId=8201 , it is related to debug/release working of FindView.

更多信息:http://aspnet.codeplex.com/workitem/8201?。PendingVoteId=8201,与FindView的调试/发布工作有关。

This was my exact problem: http://aspnet.codeplex.com/workitem/8201?PendingVoteId=8201

这就是我的问题:http://aspnet.codeplex.com/workitem/8201?

3 个解决方案

#1


1  

As Rick said, you need to profile this first. A quick test though would be to implement a no-cache controller as I outlined here: Disable browser cache for entire ASP.NET website

就像里克说的,你需要先对它进行剖析。一个快速的测试是实现一个无缓存控制器,如我在这里所描述的:为整个ASP禁用浏览器缓存。网的网站

#2


1  

If you are speaking to static types such as images and such you can add this to your web.config

如果您正在与静态类型(比如图像)对话,那么可以将其添加到web.config中

 
  

Update:

更新:

Here is a link

这里是一个链接

This link talks in detail about what you want to do.

这个链接详细地描述了你想要做什么。

#3


0  

I think you are dealing with browser cache. Have you profiled the traffic to see the 304s? You may be chasing the wrong problem.

我想你是在处理浏览器缓存。你分析交通状况看304了吗?你可能在寻找错误的问题。

NOTE: Your cache busting solution has to include the client side as well as the server-side.

注意:您的缓存破坏解决方案必须包括客户端和服务器端。


推荐阅读
  • Java实战之电影在线观看系统的实现
    本文介绍了Java实战之电影在线观看系统的实现过程。首先对项目进行了简述,然后展示了系统的效果图。接着介绍了系统的核心代码,包括后台用户管理控制器、电影管理控制器和前台电影控制器。最后对项目的环境配置和使用的技术进行了说明,包括JSP、Spring、SpringMVC、MyBatis、html、css、JavaScript、JQuery、Ajax、layui和maven等。 ... [详细]
  • 本文详细介绍了在ASP.NET中获取插入记录的ID的几种方法,包括使用SCOPE_IDENTITY()和IDENT_CURRENT()函数,以及通过ExecuteReader方法执行SQL语句获取ID的步骤。同时,还提供了使用这些方法的示例代码和注意事项。对于需要获取表中最后一个插入操作所产生的ID或马上使用刚插入的新记录ID的开发者来说,本文提供了一些有用的技巧和建议。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • 本文介绍了django中视图函数的使用方法,包括如何接收Web请求并返回Web响应,以及如何处理GET请求和POST请求。同时还介绍了urls.py和views.py文件的配置方式。 ... [详细]
  • 本文详细介绍了在Linux虚拟化部署中进行VLAN配置的方法。首先要确认Linux系统内核是否已经支持VLAN功能,然后配置物理网卡、子网卡和虚拟VLAN网卡的关系。接着介绍了在Linux配置VLAN Trunk的步骤,包括将物理网卡添加到VLAN、检查添加的VLAN虚拟网卡信息以及重启网络服务等。最后,通过验证连通性来确认配置是否成功。 ... [详细]
  • asp中如何嵌入python的简单介绍
    本文目录一览:1、如何在IIS中执行Python脚本 ... [详细]
  • ASP.NET MVC 小牛之旅3:Routing——网址路由
    网址路由(Routing)在ASP.NETMVC中有两个主要用途,一个用途是匹配通过浏览器传来的HTTP请求,另一个用途则是响应适当的网址给浏览器。3.1匹配通过浏览器传来的HTT ... [详细]
  • 在windows7中安装sqlserver2005中碰到的问题1.iis检测失败的解决办法控制面板-》程序和功能-》打开或关闭windows功能-》打开IISFeatures,点左 ... [详细]
  • OS的版本是:windows2003R2EnterpriseEditionServerPack2IIS6.0安装后,Web服务器扩展中的ASP.NETv1.1.4322也都启用, ... [详细]
  • 在springmvc框架中,前台ajax调用方法,对图片批量下载,如何弹出提示保存位置选框?Controller方法 ... [详细]
  • iOS Swift中如何实现自动登录?
    本文介绍了在iOS Swift中如何实现自动登录的方法,包括使用故事板、SWRevealViewController等技术,以及解决用户注销后重新登录自动跳转到主页的问题。 ... [详细]
  • 本文介绍了MVP架构模式及其在国庆技术博客中的应用。MVP架构模式是一种演变自MVC架构的新模式,其中View和Model之间的通信通过Presenter进行。相比MVC架构,MVP架构将交互逻辑放在Presenter内部,而View直接从Model中读取数据而不是通过Controller。本文还探讨了MVP架构在国庆技术博客中的具体应用。 ... [详细]
  • Asp.net Mvc Framework 七 (Filter及其执行顺序) 的应用示例
    本文介绍了在Asp.net Mvc中应用Filter功能进行登录判断、用户权限控制、输出缓存、防盗链、防蜘蛛、本地化设置等操作的示例,并解释了Filter的执行顺序。通过示例代码,详细说明了如何使用Filter来实现这些功能。 ... [详细]
  • 本文介绍了ASP.NET Core MVC的入门及基础使用教程,根据微软的文档学习,建议阅读英文文档以便更好理解,微软的工具化使用方便且开发速度快。通过vs2017新建项目,可以创建一个基础的ASP.NET网站,也可以实现动态网站开发。ASP.NET MVC框架及其工具简化了开发过程,包括建立业务的数据模型和控制器等步骤。 ... [详细]
  • 对hishop 商城 web.config加密,和解密码详细说明 ... [详细]
author-avatar
济河南岸_797
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有