I am making a web application that does API calls frequently. All API calls are just simple GET request, however I want to speed up loading time and output return time up as much as possible. As of right now, I'm using cURL to do the API calls by using the following:
<?php
function api_call($params)
{
$base = 'https://api.example.com/Api?';
$url = $base . http_build_query( $params );
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
return json_decode($output,true);
}
?>
Is there any ways that I can optimize this for faster download and/or output time?