I need to cache results of a PHP glob of a folder…
This folder gets files uploaded via FTP from time to time and I need to prevent the script to perform a glob every time that the page is accessed.
$file = 'content.json' ; $time = 600 ; //in seconds if(!file_exists($file)) { echo 'does not exist' ; // lets call the function that makes the glob and create the content.json } else { if( time() - filemtime( $file ) <= $time ) { echo 'file last changed under 10 mins ago' ; } else { echo 'file last changed more than 10 mins ago' ; // lets call the function that makes the glob and create the content.json } }