PHP cache question

maw

Supreme [H]ardness
Joined
Sep 27, 2000
Messages
4,135
anyone know what the code is in PHP to force the server to reload a page on each visit instead of having the browser cache it?

basically i need to check if a cookie was set on a page when i go back to it using the browser's back button, but since the browser is caching the page, it doesn't know about the cookie until i manually refresh the page.

i know how to do it in ASP, but for some reason doing somthing similar in PHP with header("Cache-control: no-cache"), doesn't seem to be working?

BTW this is PHP on an IIS server.
 
Remember when your modifying headers, you must do this at the top of the script before anything is sent out, sometimes even comments in the code can screw with headers being sent out.

PHP:
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);

// HTTP/1.0
header("Pragma: no-cache");

P.S.: The PHP site has a great online documentation system, look into it.
 
Back
Top