I’m using this script to retrieve a list of Google web fonts. How can I cache the results and use that to determine whether to load from cache or server call?
$googleFontsArray = array();
$googleFontsArrayContents = file_get_contents('http://phat-reaction.com/googlefonts.php?format=php');
$googleFontsArrayContentsArr = unserialize($googleFontsArrayContents);
foreach($googleFontsArrayContentsArr as $font)
{
$googleFontsArray[$font['font-name']] = $font['font-name'];
}
You could make a local copy of the serialized data and only update the file every hour: