首先感谢您的帮助。
最后,我得到了这个解决方案。这是简单的解决方案
首先覆盖页面的渲染方法,并在其中写入下面的代码。
//插入cookie来避免Borwser后退按钮问题
if (Request.Cookies["loadedFromServer"] != null)
Response.Cookies.Set(Request.Cookies["loadedFromServer"]);
else
Response.Cookies.Set(new HttpCookie("loadedFromServer", ""));
Response.Cookies["loadedFromServer"].Value = "true";
而在母版页写了下面的脚本。
function ClearCookie() {
var CACHE_COOKIE = 'loadedFromServer';
var loadedFromServer = getCookie(CACHE_COOKIE) == 'true';
if (loadedFromServer.toString() == "false") {
location.reload();
}
document.cookie = CACHE_COOKIE + '=' + getCookie(CACHE_COOKIE) + '; expires=Thu, 01 Jan 1970 00:00:01 UTC; path=/;';
}
function getCookie(c_name) {
var i, x, y, ARRcookies = document.cookie.split(";");
for (i = 0; i < ARRcookies.length; i++) {
x = (ARRcookies[i].substr(0, ARRcookies[i].indexOf("="))).trim();
y = (ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1)).trim();
x = x.replace(/^\s+|\s+$/g, "");
if (x == c_name) {
return unescape(y);
}
}
}
每次在主页面调用该函数。
禁用浏览器后退按钮 - 我能够在回应中实现三个缓存控制标题。 “no-cache,no-store,must-revalidate”,但还剩下1个标题,即max-age = 0。我无法得到这个标题。如何获得最大年龄头? –
不确定您使用的服务器脚本语言。作为一个例子,你可以像'response.setHeader(“Cache-Control”,“no-cache,max-age = 0,must-revalidate,no-store”);' – woodykiddy
这个问题在很多地方都存在。这是最好的答案。如果你使用PHP,代码是:header('Cache-Control:no-cache,max-age = 0,must-revalidate,no-store'); –