在IE浏览器中,总是从浏览器加载旧数据

In IE browser always load the old data from the brower

本文关键字:浏览器 加载 数据 IE      更新时间:2023-09-26

在IE浏览器中,始终从浏览器历史记录加载旧数据。为了获得最新的数据,我需要始终清除浏览器历史记录。

如何始终加载新数据?有没有办法使用javascript清除浏览历史记录?

这似乎是因为对于临时互联网文件和网站文件

我试过几种方法,比如

<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='-1'>
<meta http-equiv='pragma' content='no-cache'>
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
      response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
      response.setDateHeader("Expires", 0); // Proxies.
var numberOfEntries = window.history.length;
    window.history.go(-numberOfEntries); 
    var cookies = document.cookie.split(";");
    for (var i = 0; i < cookies.length; i++) {
        var cookie = cookies[i];
        var eqPos = cookie.indexOf("=");
        var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
        document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
    }
    window.history.replaceState();
      window.location.replace(document.url);

似乎什么都不起作用

您是否尝试过在每次加载页面时以某种方式更改页面,以查看浏览器停止缓存旧页面。

您可以尝试在页面中放置一个隐藏的输入元素,然后在每个元素上更新其值页面加载,查看是否足以强制浏览器显示页面的最新版本。

以下是jsfiddle的链接:http://jsfiddle.net/larryjoelane/nu1jpvjh/1/

html部分:

 <input id="version" type = "hidden" value = "1">

jquery部分:

      //the highest number you want to retrieve randomly
      var upperLimit = 1000;
     //get random number between 1 and 1000
    //change upperlimit above to increase or 
   //decrease range
    var randomNum = Math.floor((Math.random() * upperLimit) + 1);    

  //update the #version input box value
  $("#version").val(randomNum);