【问题标题】:IE8 is still caching my requests even with mathrandom即使数学随机,IE8 仍能捕捉到我的请求
【发布时间】:2011-03-01 11:36:32
【问题描述】:

TLDR IE 仍在缓存我的请求,即使 URL 中包含 Math.random()。


所以我在网址的末尾添加了数学随机数:

var MYKMLURL = 'http://' + host + 'data/pattern?key='+ Math.random();

我还在函数参数中添加了数学随机数:

window.setTimeout(RefreshPatternData, 1000, MYKMLLAYER);


           function RefreshPatternData(layer) {
               layer.loaded = false;
               layer.setVisibility(true);
               layer.refresh({ force: true, params: { 'key': Math.random()} });
               setTimeout(RefreshPatternData, 30000, MYKMLLAYER);
           }

所以请求显示为http://host/data/pattern?key=35678652545 等。

每次请求都会改变。

它适用于 Firefox & Chrome & Safari 等。但 IE8 仍在缓存数据而不更新我的图层。

关于为什么会发生这种情况的任何想法?


所以我补充说:

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">

仍在缓存数据。还有什么想法吗?

【问题讨论】:

  • 哦,我以前见过这个。 IE 在缓存方面是脑残,并且会缓存所有可见的内容,即使服务器另有说明。否则需要几个神奇的 HTTP 标头才能说服它......
  • 我也有同样的问题。元标记在 IE8 中不起作用。我只能使用 F12 开发者工具中的一个选项来禁用客户端的缓存。

标签: javascript jquery internet-explorer caching openlayers


【解决方案1】:

你可以试试这个帖子的答案:

Prevent IE caching

【讨论】:

  • 我搜索了所以没有找到那个问题谢谢你的链接:)
【解决方案2】:

我在 IE 上遇到了类似的问题,它缓存了 AJAX 请求。 (为什么,上帝,你为什么要缓存 AJAX 请求?)在其他所有方面都工作得很好,但 IE 需要通过 HTTP 标头强制不缓存 AJAX 请求。

我早就忘记了网址,但请参阅: http://greenash.net.au/thoughts/2006/03/an-ie-ajax-gotcha-page-caching/

另外,为我做的 HTTP 标头是:

Pragma: no-cache
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0

...老实说,我是从某个网站上收集到的。

【讨论】:

    猜你喜欢
    • 2023-01-30
    • 2021-05-11
    • 1970-01-01
    • 2010-12-29
    • 2016-04-23
    • 2014-08-15
    • 1970-01-01
    • 2018-10-24
    相关资源
    最近更新 更多