あるAPIを試していたら、あっという間に試用上限に達してしまったので、早い段階でキャッシュする習慣にしたほうがいいかな、と。そのうち多機能にします。
function file_get_contents_cache($url){
$cache_path = "cache/".md5($url);
if( file_exists($cache_path) ){
$contents = file_get_contents($cache_path);
}else{
$contents = file_get_contents($url);
file_put_contents($cache_path,$contents);
}
return $contents;
}