3

TLDR IE is still caching my requests even with Math.random() included in the URL.


So I added math random onto the end of my url:

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

I also added math random onto my function param:

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);
           }

So the request appears as http://host/data/pattern?key=35678652545 etc.

It changes everytime the request is made.

It works in Firefox & Chrome & Safari etc. But IE8 is still caching the data and not updating my layer.

Any ideas as to why this might be occuring?


So i added:

<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">

Still is caching the data. Any further ideas?

Sphvn
  • 5,247
  • 8
  • 39
  • 57
  • 1
    Oh, I've seen this one before. IE is braindead when it comes to caches, and will cache everything in sight, even if the server says otherwise. It takes a couple of magic HTTP headers to convince it otherwise... – Thanatos Jun 09 '10 at 03:38
  • I have the same problems. The meta tags don't work in IE8. I was only able to disable caching on the client-side with an option in the F12 developer tools. – Benny Code Apr 17 '13 at 11:18

2 Answers2

2

You could try the answers to this post:

Prevent IE caching

Community
  • 1
  • 1
Lauri Lehtinen
  • 10,647
  • 2
  • 31
  • 29
2

I had a similar issue with IE and it caching AJAX requests. (Why, God, why would you cache an AJAX request?) Worked fine in everything else, but IE required coercing via HTTP headers to not cache the AJAX request.

I've long forgotten the URL, but see: http://greenash.net.au/thoughts/2006/03/an-ie-ajax-gotcha-page-caching/

Also, the HTTP headers that did it for me were:

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

...which I quite honestly gleaned off a website somewhere.

Thanatos
  • 42,585
  • 14
  • 91
  • 146