简体   繁体   English

与ASP .NET MVC4和IIS6一起使用时,浏览器正在缓存AngularJS视图

[英]Browser is caching AngularJS views when used with ASP .NET MVC4 & IIS6

I'm using AngularJS on client side and ASP .NET MVC4 as a framework. 我在客户端使用AngularJS,并将ASP .NET MVC4用作框架。 Application is hosted on IIS6. 应用程序托管在IIS6上。 Unfortunately after each release I get feedback that some pages don't work. 不幸的是,在每个版本之后,我都收到一些页面无法使用的反馈。 I turned out that AngularJS requests for views, eg. 我发现AngularJS请求视图,例如。

/AppName/Home/Index

are returning 304 status code (I have no idea why...) and browser is using old template. 正在返回304状态代码(我不知道为什么...),并且浏览器正在使用旧模板。 Only hard refresh (ctrl + f5) helps. 仅硬刷新(ctrl + f5)有帮助。

Is there a way to configure IIS6 or ASP .NET MVC4 or change web.config in order to prevent browser from caching the views? 有没有一种方法可以配置IIS6或ASP .NET MVC4或更改web.config,以防止浏览器缓存视图?

Try to mark actions for views that you dont want to cache with OutputCache attribute like this: 尝试使用OutputCache属性为不想缓存的视图标记操作,如下所示:

 [OutputCache(NoStore = true, Duration = 0, VaryByParam = "None")]

It will disable MVC lavel cache. 它将禁用MVC lavel缓存。 After that browser can still keep some cache. 之后,浏览器仍然可以保留一些缓存。 To prevent this try to use something like this . 为了防止这种情况,请尝试使用类似这样的方法

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

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