You can make a local copy of serialized data and only update the file every hour:
$cache_file = 'font_cache';
$update_cache = false;
$source = $cache_file;
if(!file_exists($cache_file) || time() - filemtime($cache_file) >= 3600)
{
$source = 'http://phat-reaction.com/googlefonts.php?format=php';
$update_cache = true;
}
$googleFontsArray = array();
$googleFontsArrayContents = file_get_contents($source);
$googleFontsArrayContentsArr = unserialize($googleFontsArrayContents);
foreach($googleFontsArrayContentsArr as $font)
{
$googleFontsArray[$font['font-name']] = $font['font-name'];
}
if($update_cache)
{
file_put_contents($cache_file, $googleFontsArrayContents);
}
source
share