[英]Asp.net mvc view/page reloaded from browse cache when using browser back button in Safari
I have Asp.net MVC page/view is always fetched from cache when using browser back button. 使用浏览器后退按钮时,我总是从缓存中获取Asp.net MVC页面/视图。 This issue is with safari browser alone and works properly in other browser such as Chrome,Firefox and IE.
这个问题仅与Safari浏览器有关,并且可以在其他浏览器(例如Chrome,Firefox和IE)中正常运行。 I went through so many posts which describes similar issues.
我浏览了很多描述类似问题的帖子。 But till now I am not able find a solution for this .
但是到目前为止,我还无法找到解决方案。
This is below code from my action method 这是我的动作方法下面的代码
[OutputCache(Duration = 0, Location = OutputCacheLocation.Any, VaryByParam = "*")]
public ActionResult ABC(string taxonomy)
{
return View()
}
In safari response shows the below 在野生动物园中的响应显示以下内容
Cache-Control:public, max-age=0, s-maxage=0
Connection:Close
Content-Length:15849
Content-Type:text/html; charset=utf-8
Date:Wed, 12 Nov 2014 06:07:55 GMT
Expires:Wed, 12 Nov 2014 06:07:52 GMT
Last-Modified:Wed, 12 Nov 2014 06:07:52 GMT
Server:ASP.NET Development Server/10.0.0.0
Vary:*
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:4.0
I have also tried added the bleow code to the action method 我也尝试过将bleow代码添加到action方法中
[OutputCache(Duration = 0, Location = OutputCacheLocation.Any, VaryByParam = "*")]
public ActionResult ABC(string taxonomy)
{
HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Response.AppendHeader("Cache-Control", "private, no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, s-maxage=0"); // HTTP 1.1.
HttpContext.Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0.
HttpContext.Response.AppendHeader("Expires", "0"); // Proxies.
HttpContext.Response.AppendHeader("Vary", "*");
}
So the response was like below 所以响应如下
Cache-Control:no-cache
Connection:Close
Content-Length:15849
Content-Type:text/html; charset=utf-8
Date:Wed, 12 Nov 2014 06:20:58 GMT
Expires:-1
Pragma:no-cache, no-cache
Server:ASP.NET Development Server/10.0.0.0
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:4.0
But what ever i do the the safari get's the page from cache when i use the back button of the browser. 但是,当我使用浏览器的后退按钮时,我从野生动物园获取野生动物园的页面的方法是什么。 Kindly help with solution /suggestion to solve this problem .
请提供解决方案/建议来解决此问题。
I had similar problem with Safari and adding onunload=""
in body tag and I solved it. 我在Safari中遇到了类似的问题,并在body标签中添加了
onunload=""
,我解决了它。 Check: Preventing cache on back-button in Safari 5 检查: 在Safari 5中防止在后退按钮上缓存
I found this alternative approach which solved my problem . 我找到了解决问题的替代方法。 Hope this help everyone facing similar issues How do you disable back and forward caching on iOS Safari?
希望这对遇到类似问题的所有人有所帮助。 如何在iOS Safari上禁用前进和后退缓存?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.