2010-06-07 77 views
0

我试图从后退按钮导航时刷新页面。从我的理解了解了一下后,我应该只需要将页面标记为不可缓存,但我无法使用任何浏览器来刷新页面。这些是我目前得到的标题:需要什么HTTP标头刷新返回按钮上的页面

Cache-Control:no-cache 
Connection:keep-alive 
Content-Encoding:gzip 
Content-Length:1832 
Content-Type:text/html; charset=utf-8 
Date:Mon, 07 Jun 2010 14:05:39 GMT 
Expires:-1 
Pragma:no-cache 
Server:Microsoft-IIS/7.5 
Vary:Accept-Encoding 
Via:1.1 smoothwall:800 (squid/2.7.STABLE6) 
X-AspNet-Version:2.0.50727 
X-AspNetMvc-Version:2.0 
X-Cache:MISS from smoothwall 
X-Powered-By:ASP.NET 

为什么浏览器将此页面从浏览器历史记录中拉出而不刷新它?

回答

0

想通了。这是我找到的工作:

Cache-Control:no-cache, no-store 
Connection:Close 
Content-Length:7683 
Content-Type:text/html; charset=utf-8 
Date:Wed, 09 Jun 2010 03:37:38 GMT 
Expires:-1 
Pragma:no-cache 
Server:ASP.NET Development Server/9.0.0.0 
X-AspNet-Version:2.0.50727 
X-AspNetMvc-Version:2.0 

用下面的ASP.NET代码来实现:

Response.Cache.SetCacheability(HttpCacheability.NoCache); 
Response.Cache.SetAllowResponseInBrowserHistory(false); 
Response.Cache.SetMaxAge(new TimeSpan(0)); 
Response.Cache.SetNoStore(); 
Response.Cache.SetExpires(new DateTime(1940, 1, 1)); 
+0

这是不正确的,有了这个代码的网页过期警告将被显示。你说过,你想要刷新页面。 – 2010-12-27 09:04:47

+0

真的吗?哪些浏览器会这样做?我们已经有一段时间使用这段代码了,它看起来像我们想要的那样工作 - 即:在后退按钮页面被从服务器重新请求,而不是来自缓存。究竟是什么意思,页面过期警告 - 这是用户会这样? – 2011-01-05 01:22:15