If you enjoy this tool, please star this Gist! Author: fakerybakery (mrfakename). URL: https://gist.github.com/fakerybakery/df33cb8890da4ebf9e46f8a72e486f00
Heavily modified from: https://stackoverflow.com/a/18097502
Code:
function fgc($url) {
$cache_file = 'cache/' . md5($url);
if(file_exists($cache_file)) {
if(time() - filemtime($cache_file) > 3600) {
$cache = file_get_contents($url);
file_put_contents($cache_file, $cache);
} else {
$cache = file_get_contents($cache_file);
}
} else {
$cache = file_get_contents($url);
file_put_contents($cache_file, $cache);
}
return $cache;
}
Modifications licensed under AGPL-3.0