Created
March 4, 2009 11:15
-
-
Save deplorableword/73799 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$cacheFile = 'cache/cache.html'; | |
$cacheTime = 4 * 60; | |
// Serve the cached file if it is older than $cacheTime | |
if (file_exists($cacheFile) && time() - $cacheTime < filemtime($cacheFile)) { | |
include($cacheFile); | |
exit; | |
} | |
// Start the output buffer | |
ob_start(); | |
// put your shit here | |
// Cache the contents to a file | |
$cached = fopen($cacheFile, 'w'); | |
fwrite($cached, ob_get_contents()); | |
fclose($cached); | |
ob_end_flush(); // Send the output to the browser | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment