Note that there are some explanatory texts on larger screens.

plurals
  1. POphp curl - long redirect time in curl_getinfo()
    primarykey
    data
    text
    <p>The code works, but it takes up to 10 seconds to load the page. Then I add curl_getinfo(), and discovered the redirect time has used 90% of the total time....</p> <pre><code>&lt;?php // $url = "http://www.somesite.com/###"; $username = 'username'; $password = 'password'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookies.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookies.txt'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); $out = curl_exec($ch); print "error:" . curl_error($ch) . "&lt;br /&gt;"; print "output:" . $out . "&lt;br /&gt;&lt;br /&gt;"; $info = curl_getinfo($ch); print_r($info); curl_close($ch); ?&gt; </code></pre> <p>curl_getinfo() shows:</p> <pre><code>Array ( [url] =&gt; http://www.somesite.com/xxx [content_type] =&gt; text/xml;charset=UTF-8 [http_code] =&gt; 200 [header_size] =&gt; 2760 [request_size] =&gt; 5576 [filetime] =&gt; -1 [ssl_verify_result] =&gt; 0 [redirect_count] =&gt; 3 [total_time] =&gt; 10.751595 [namelookup_time] =&gt; 2.0E-5 [connect_time] =&gt; 0.001612 [pretransfer_time] =&gt; 0.001613 [size_upload] =&gt; 0 [size_download] =&gt; 24506 [speed_download] =&gt; 2279 [speed_upload] =&gt; 0 [download_content_length] =&gt; 24506 [upload_content_length] =&gt; 0 [starttransfer_time] =&gt; 0.62479 [redirect_time] =&gt; 9.080637 &lt;-------------- [certinfo] =&gt; Array ( ) [redirect_url] =&gt; ) </code></pre> <p>See <code>[redirect_time] =&gt; 9.080637</code> ?</p> <p>It takes up 90% of the total time.</p> <p>How to improve it?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload