'Check for newer versions of stored pages'

Hi,

I'm using AJAX on my website, but internet explorer does not seem to actually be refreshing the data I retrieve via AJAX when I refresh the page. For example, I have a button that when pressed uses an XMLHttpRequest to go read some data from a database then returns it to the browser for display. It looks like:

    Press button
    XMLHttpRequest gets data from db
    XMLHttpRequest renders returned data in client browser

I can update the records in the database, ask the page to retrieve data but it doesn't seem to 'see' the new records unless I close the browser, and open a new instance. Then it picks up the changes.

Also if I go into the IE settings and choose 'Check for newer versions of stored pages: Every visit to the page' it works perfectly.

I can't rely on users to have chosen that setting though, so what can I do to get around this behaviour?

Thanks
LVL 7
minnirokAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimYatesCommented:
put the current time in milliseconds into the URL as a parameter

    ajaxobj.open( 'GET', 'yoururl.php?t=" + new Date().getTime(), true ) ;

It will fool the browser into getting a new version of the page rather than just reading it from the cache :-)

Tim
0
minnirokAuthor Commented:
Hi Tim,

Right now I'm already passing some params to my php script like:

    function DoIt()
    {  
        var vParams = "apple" + "," "orange";

        httpGetStuff.open("GET", "myScript.php?param=" + vParams, true);
    }

How can I incorporate that time stamp?

Thanks

     
0
TimYatesCommented:
      httpGetStuff.open("GET", "myScript.php?param=" + vParams + "&cachebuster=" + new Date().getTime(), true);

should do it :-)

And you may want to escape your params, just incase of spaces, quotes, etc...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
minnirokAuthor Commented:
tres chouvette, merci beaucoup!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.