即使 URL 中包含 Math.random(), TLDR IE 仍在缓存我的请求。
所以我在我的网址末尾添加了数学随机:
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">
仍在缓存数据。还有什么想法吗?