PHP refresh content

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
camac
Forum Newbie
Posts: 3
Joined: Thu Jul 27, 2006 10:41 pm

PHP refresh content

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

sounds like you have a caching problem.
camac
Forum Newbie
Posts: 3
Joined: Thu Jul 27, 2006 10:41 pm

Post by camac »

feyd wrote:sounds like you have a caching problem.
Ok. Do you know of a way to fix this?
Thanks
Regards
Cameron
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
camac
Forum Newbie
Posts: 3
Joined: Thu Jul 27, 2006 10:41 pm

Post 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
?>
Post Reply