Iam using cUrl (php) to get code html of webpage. It run very fast on localhost ( time waiting: 700ms ). But when I deploy to live server, it run very slow ( time waiting: 5, 6s ). How i fix it ?
function getHTML($url,$timeout)
{
$ch = curl_init($url); // initialize curl with given url
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.001 (windows; U; NT4.0; en-US; rv:1.0) Gecko/25250101');
return @curl_exec($ch);
}
and here result when i print_r( curl_getinfo($ch) ):
Array (
[url] => http://vozforums.com/showthread.php?t=6693
[content_type] => text/html; charset=UTF-8
[http_code] => 200
[header_size] => 535
[request_size] => 195
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 2.375209
[namelookup_time] => 0.000561
[connect_time] => 0.310456
[pretransfer_time] => 0.310458
[size_upload] => 0
[size_download] => 107726
[speed_download] => 45354
[speed_upload] => 0
[download_content_length] => 107726
[upload_content_length] => 0
[starttransfer_time] => 0.74337
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => 1xx.xx.xx.xx
[certinfo] => Array ( )
)