$cache_file = getcwd().'/filename.cache';
if (file_exists($cache_file) && (filemtime($cache_file) > (time() - 60 * 9 ))) {
header('Content-Type: application/json');
echo file_get_contents($cache_file);
} else {
$feed = "content to cache";
file_put_contents($cache_file, $feed, LOCK_EX);
echo $feed;
}
Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.