title: cURL slow starttransfer_time
body: <p>Good Day!</p>
  
  <p>cURL is acting very slow when requesting a page. I know its not the page requested, because  the page returns in the browser instantly.</p>
  
  <p>2 things I've noticed</p>
  
  <ul>
  <li>The starttransfer_time is regularly almost 20</li>
  <li>The local_port seems to change every time. Is that normal?</li>
  <li>Occasionally, cURL will respond instantly</li>
  </ul>
  
  <p>I have the following code:</p>
  
  <pre><code>$ch = curl_init(); 
  curl_setopt($ch, CURLOPT_URL, $url ); 
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_POST, false);
  $output = curl_exec($ch); 
  curl_close($ch); 
  </code></pre>
  
  <p>Echoing curl_getinfo() gives me the following</p>
  
  <pre><code>[url] =&gt; http://127.0.0.1:80/wpengine/?json=t
  [content_type] =&gt; text/html; charset=iso-8859-1
  [http_code] =&gt; 302
  [header_size] =&gt; 215
  [request_size] =&gt; 64
  [filetime] =&gt; -1
  [ssl_verify_result] =&gt; 0
  [redirect_count] =&gt; 0
  [total_time] =&gt; 17.238
  [namelookup_time] =&gt; 0
  [connect_time] =&gt; 0
  [pretransfer_time] =&gt; 0
  [size_upload] =&gt; 0
  [size_download] =&gt; 221
  [speed_download] =&gt; 12
  [speed_upload] =&gt; 0
  [download_content_length] =&gt; 221
  [upload_content_length] =&gt; 0
  [starttransfer_time] =&gt; 17.238
  [redirect_time] =&gt; 0
  [certinfo] =&gt; Array
      (
      )
  
  [primary_ip] =&gt; 127.0.0.1
  [primary_port] =&gt; 80
  [local_ip] =&gt; 127.0.0.1
  [local_port] =&gt; 51875
  [redirect_url] =&gt; 
  </code></pre>
  
  <p>Can anyone give me some pointers on how to figure out what is going on?</p>
  
  <p>Here are a few lines from the Apache access log</p>
  
  <pre><code>127.0.0.1 - - [06/Dec/2013:12:01:22 -0500] "GET /wpengine/?json=t HTTP/1.1" 302 221
  127.0.0.1 - - [06/Dec/2013:12:01:12 -0500] "GET /community HTTP/1.1" 200 6266
  127.0.0.1 - - [06/Dec/2013:12:01:22 -0500] "GET /public/js/jquery.js?b=10 HTTP/1.1" 304 -
  </code></pre>