6th January 2009 - 3 minutes read time
One issue, especially when creating AJAX applications, is that the browser can cache the contents of the page so that when a similar request is made the same content is presented.
To force the browser to present the content you want it to without caching you can add the following headers to your page.
header("HTTP/1.1 202 Accepted");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, proxy-revalidate, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Cache-Control: max-age=10000000, s-maxage=1000000");
header("Pragma: no-cache");
Remember to put this before you print out any content as you will get some nice looking errors otherwise.
Also, I wouldn't put this on every page on the site as it can create an overhead that just isn't needed.