Find a way to update rss for custom

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

Or any better way to suggest me? Many thanks.

Would this not work?

$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
}

Thanks, maybe this is a better method.

By the way, to show the xml file which one is faster? include($filename) or get_file_contents($filename) ?

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
}  

OK, I think I also will choose file_get_contents(), thanks again