I am design a website, witch could allow custom to give rss from search result. To avoid a large query, the best way may be create static .xml files. Then according the xml create date, do an automatic update per 24 hours.
I think the better way is use php to make a judge, if time()-filectime>246060, do a .xml update, else just read the old .xml file. But, how to do this judge? custom will read the .xml directly, and xml can not make a time()-filectime
$filename = 'path/and_name_of_the_file.xml';
if(file_exists($filename) && filectime($filename)+(24*60*60) > time()){
// show the old xml file
} else {
// modify the xml file and show it
}
I would use file_get_contents() because then you can still manipulate the file contents like so:
$filename = 'path/and_name_of_the_file.xml';
if(file_exists($filename) && filectime($filename)+(24*60*60) > time()){
$contents = file_get_contents($filename);
// do stuff with contents if you need
echo $contents;
} else {
// modify the xml file and show it
}
Ofcourse you could also use include() and a buffer.
$filename = 'path/and_name_of_the_file.xml';
if(file_exists($filename) && filectime($filename)+(24*60*60) > time()){
ob_start();
include($filename);
$contents = ob_get_contents();
ob_end_clean();
// do stuff with the contents if you need
echo $contents;
} else {
// modify the xml file and show it
}