IE 7 caching problem

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
coderb
Forum Newbie
Posts: 7
Joined: Mon Mar 10, 2008 1:10 pm

IE 7 caching problem

Post by coderb »

Hi All,

I've got a simple AJAX routine that populates an incrementing field based on a ddl selected item.

it works fine, but when I go back into the page, select the same item from the ddl, it should cause the field value to increment again, but IE 7 just repopulates it with the cached value - no doubt it assumes that because the selected value has not changed, I don't need a new result.

I thought that adding the following the parent page would do the trick:

this added before any html:
Header("Cache-control: private, no-cache");
Header("Expires: Mon, 26 Jun 1997 05:00:00 GMT");
Header("Pragma: no-cache");
Header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");

this in <head> tag:
<META http-equiv="expires" content="0">

but still IE 7 does not work. Firefox, Opera and Safari are fine.
when I delete the IE browsing history, then try again IE increments the value correctly.
so how can I force IE 7 not to cache this value or not use the cached value?

thanks for any help..
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: IE 7 caching problem

Post by kaszu »

As i understood, your problem is that ajax request gets cached.
Easiest solution i guess would be adding random value to the request uri

Code: Select all

var ajax_request_uri = '...?random=' + Math.random();
Post Reply