How to speed up cURL in php?

The final solution for speed up is this

curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );

Regards


The best speed up I've ever had was reusing the same curl handle. Replace $ch = curl_init( $json_url ); with curl_setopt($ch, CURLOPT_URL, $url);. Then outside the functions have one $ch = curl_init();. You'll need to make $ch global in the functions to access it.

Reusing the curl handle keeps the connection to the server open. This only works if the server is the same between requests, as yours are.

Tags:

Php

Rest

Twitter