What HTTP headers are required to refresh a page on back button

廉价感情. 提交于 2021-01-29 17:49:04

问题


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?


回答1:


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

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


来源:https://stackoverflow.com/questions/2990307/what-http-headers-are-required-to-refresh-a-page-on-back-button

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!