increase cURL response speed? [closed]

2

I'm using a google API and I'm testing it with the code below, but there's a huge difference in loading directly through the browser and PHP, it takes a long time for PHP, is there any way to "speed it up"? >

    $this -> curl = curl_init();
    curl_setopt($this -> curl, CURLOPT_URL, ltrim($this -> queryURL() . '&q=' . urlencode($this -> query)));
    curl_setopt($this -> curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($this -> curl, CURLOPT_RETURNTRANSFER, 1);
    $this -> response = curl_exec($this -> curl);

    curl_close($this -> curl);
    
asked by anonymous 14.09.2016 / 17:29

1 answer

0

Some other timeout options before curl_exec :

curl_setopt($this -> curl, CURLOPT_CONNECTTIMEOUT, 1); // espera 1 segundo para conectar

curl_setopt($this -> curl, CURLOPT_TIMEOUT, 10); // espera ateh 10 segundos no envio de comandos

Based on: link

Oh, and there is the option to pass the parameters in ms: CURLOPT_CONNECTTIMEOUT_MS and CURLOPT_TIMEOUT_MS

    
14.09.2016 / 18:16