You can add to your php code a cache function.
When you load the random text, write it into /cache/mytext.cache
and write an unix timestamp into /cache/mytext.info
Now, on top of your php script, read /cache/mytext.info
and check if it's too old, if so, generate a new text and update the timestamp of mytext.info, else, load as text the content of /cache/mytext.cache
// Fetch the timestamp saved in /cache/mytext.info
$cachedate = file_get_contents('./cache/mytext.info', true);
// If timestamp + _× seconds_ is < of current time
if(($cachedate + 3600) < time()) {
// Fetch your new random text and store into $mytext
// for example: $mytext = getrandomtext();
// Write into /cache/mytext.cache your new random text
$fp = fopen('./cache/mytext.cache', 'w');
fwrite($fp, $mytext);
fclose($fp);
// Update timestamp written into /cache/mytext.info
$fp = fopen('./cache/mytext.info', 'w');
fwrite($fp, time());
fclose($fp);
}
// Your random text is into $mytext
$mytext = file_get_contents('./cache/mytext.cache', true);
// Print it with echo
echo $mytext;