在后退按钮上刷新页面需要哪些HTTP标头 [英] What HTTP headers are required to refresh a page on back button

查看:51
本文介绍了在后退按钮上刷新页面需要哪些HTTP标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图让页面从后退按钮导航到时刷新.根据我的理解,在阅读了一些内容之后,我只需要将该页面标记为不可缓存,但是我无法让任何浏览器来刷新页面.这些是我目前拥有的标题:

I'm trying to get a page to refresh when navigated to from the back button. From what I understand after reading around a bit I should just need to mark the page as uncacheable but I can't get any browsers to refresh the page. These are the headers I've currently got:

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

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

Why would the browser pull this page from it's browser history and not refresh it?

推荐答案

弄清楚了.这是我发现可以正常工作的地方:

Figured it out. This is what I found to work:

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代码实现:

achieved with the following ASP.NET code:

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));

这篇关于在后退按钮上刷新页面需要哪些HTTP标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆