Add Transient Caching
-
Had a major issue with cURL requests on one server resulting in fatal errors, which is never good… It produces this error a result of failing wp_remote_get.
To address this and do it more properly, the plugin should most definitely use transient caching instead of making the request for every page. Consider also that the Vimeo API has a hit rate limit, a very busy site could have issues.So here are my changes (currently in production) for plugin update’s consideration:
//$videos_result = wp_remote_get($vmg_videos_url);
//$vmg_videos = simplexml_load_string($videos_result[‘body’]);
if (false === ($videos_result = get_transient(‘vmg_videos’) ) ){
if ($videos_result = wp_remote_retrieve_body( wp_remote_get($vmg_videos_url) )){
set_transient(‘vmg_videos’, $videos_result, 7200);//2 hours
}
}
$vmg_videos = $videos_result ? simplexml_load_string($videos_result) : false;///$info_result = wp_remote_get($vmg_info_url);
//$vmg_info = simplexml_load_string($info_result[‘body’]);
if (false === ($info_result = get_transient(‘vmg_info’) ) ){
if ($info_result = wp_remote_retrieve_body( wp_remote_get($vmg_info_url) )){
set_transient(‘vmg_info’, $info_result, 7200);//2 hours
}
}
$vmg_info = $info_result ? simplexml_load_string($info_result) : false;
- The topic ‘Add Transient Caching’ is closed to new replies.