Archive for November, 2007
IE Cacheing AJAX requests
by Chris on Nov.29, 2007, under Computers
So for the past couple of days I’m been programming like crazy to create a set of member pages for the CYC’s web site. Everything was looking good in Firefox so I decided to check the page in IE7.
This is when I quickly realised that IE caches AJAX requests (which seems to defeat the purpose of AJAX in my opinion). So off to google I go to see what I can find about fixing this.
I found one site that suggested adding php headers to the page (http://www.greenash.net.au/posts/thoughts/an-ie-ajax-gotcha-page-caching) but I knew that wouldn’t work, since you can’t send headers to page that already exists.
So back to the web I went. I found another blog (http://www.howtoadvice.com/StopCaching) that suggested adding a unique var to the URL. So I added in this little line of code in my AJAX PHP functions:
$URL .= “&ms=” . date(“U”);
And after that it worked perfectly.
At some point I should give more information on the AJAX framework I use. It’s basically a single javascript file, a PHP file full of functions and then the actually PHP pages to run the requests. I could probably compile it all into one file, but I find it easier to manage as multiple files.