Page 1 of 1

PHP refresh content

Posted: Thu Jul 27, 2006 10:45 pm
by camac
Hey all,
I am currently creating a website and it has a generic ID number generated by the date() command in php my problem is, whenever I want to change this ID I have to refresh the page, (navigating to the page does not change it). how can I make it so that whenever the page is displayed the new generic code shows up?
Also I have already tried the <?php Header(Location: [url]) ?> method and it did nothing either
Thank-you in advance
Regards
Cameron

Posted: Thu Jul 27, 2006 10:52 pm
by feyd
sounds like you have a caching problem.

Posted: Thu Jul 27, 2006 11:01 pm
by camac
feyd wrote:sounds like you have a caching problem.
Ok. Do you know of a way to fix this?
Thanks
Regards
Cameron

Posted: Thu Jul 27, 2006 11:11 pm
by feyd
There are many possible solutions. One is to make the URL unique so the browser has less of a chance to cache the page, another to tell the browser not to cache the page via header(). We've had several threads on "no-cache" headers, so I'll talk a bit about the unique URL, which is quite simple really.

The page(s) linking to the page can include a randomized argument such as that returned from uniqid(), mt_rand() or some other functions available in php.

Posted: Thu Jul 27, 2006 11:50 pm
by camac
Thanks i've fixed it! I told the browser to to cache it! with this code :wink:
<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
?>