【发布时间】: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