php加载api非常慢

I have this code, as a php file, I include it in the index and presenting the BTC/ETH values, the site loading is very slow, any suggestion what can I do so it run faster? maybe I do something wrong here with the code, im new with json :).

Thanks for helping!

    <?php

function getCryptoPrices($url)
{
    $decode = file_get_contents($url);
    return json_decode($decode, true);
}

/* BTC USD */
$BTC_USD = getCryptoPrices('https://www.bitstamp.net/api/ticker/');
$BTC_VALUE = $BTC_USD['last'];

/* ETH USD */
$ETH_USD = getCryptoPrices('https://www.bitstamp.net/api/v2/ticker/ethusd/');
$ETH_VALUE = $ETH_USD['last'];


session_start();

$_SESSION['BTC'] = $BTC_VALUE;
$_SESSION['ETH'] = $ETH_VALUE;

?>

You can user CURL for read content in urls very fast.. you must install "curl" in your server if it's not there then try this function .

$returned_content = get_data('https://www.bitstamp.net/api/ticker/'); 

The Code

function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}