title: Waitting Time ( TTFB ) is above 4 seconds result from `get_headers()`
body: <p>I am using Apache version ( httpd-2.4.10-win64-VC11 ) on windows 2012. I am trying to do that when click on image item it would open dialog with inforamation about this item. I do this with :</p>
  
  <pre><code>var self = $(this),
    vaid = "1",
    btnhref = self.attr('href'),
    itemID = getVar("item",btnhref);
  
  $.ajax({
    type: 'POST',
    url: '/action.php',
    data: {"itemID" : itemID},
    dataType: 'json',
    beforeSend: function(xhr) {                     
      xhr.setRequestHeader('va', vaid);                                  
    },
    statusCode: {
      401:function() { Validation('401 Unauthorized&lt;/br&gt;Error: Invalid Action'); }
    },
    complete: function()
    {       
      var state = {
        "dialog": true
      };
      history.pushState(state, document.title, btnhref);                              
    },
    success: function(response){},
    cache: true,
    contentType: "application/x-www-form-urlencoded",
    processData: true
  });
  </code></pre>
  
  <p>The problem is that the response is very slow and I am unable to find the reason for it. Below I add the data I received from chrome speed tracer.</p>
  
  <p>P.S : I am using cloudfront for images , CSS &amp; Javascripts files . </p>
  
  <p><a href="http://i.stack.imgur.com/UEh2Q.png" rel="nofollow">http://i.stack.imgur.com/UEh2Q.png</a></p>
  
  <p><strong>EDIT :</strong> This details from fiddler web debugger: ( with GET or POST the same results )</p>
  
  <p>== TIMING INFO ============</p>
  
  <p>ClientConnected:    13:53:10.037</p>
  
  <p>ClientBeginRequest: 13:53:10.064</p>
  
  <p>GotRequestHeaders:  13:53:10.064</p>
  
  <p>ClientDoneRequest:  13:53:10.064</p>
  
  <p>Determine Gateway:  0ms</p>
  
  <p>DNS Lookup:         1ms</p>
  
  <p>TCP/IP Connect: 16ms</p>
  
  <p>HTTPS Handshake:    0ms</p>
  
  <p>ServerConnected:    13:53:10.080</p>
  
  <p>FiddlerBeginRequest:    13:53:10.080</p>
  
  <p>ServerGotRequest:   13:53:10.080</p>
  
  <p>ServerBeginResponse:    13:53:10.593</p>
  
  <p>GotResponseHeaders: 13:53:10.593</p>
  
  <p><strong>ServerDoneResponse:   13:53:15.366</strong></p>
  
  <p>ClientBeginResponse:    13:53:15.366</p>
  
  <p>ClientDoneResponse: 13:53:15.366</p>
  
  <p><strong>Apache Log : LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined</strong> </p>
  
  <pre><code>37.8.80.203 - - [04/Apr/2015:11:06:13 +0000] "GET /shadiCo/item/146 HTTP/1.1" 200 33640 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
  37.8.80.203 - - [04/Apr/2015:11:06:20 +0000] "POST /method/pusher HTTP/1.1" 200 96 "http://localhost/shadiCo/item/146" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
  37.8.80.203 - - [04/Apr/2015:11:06:20 +0000] "POST /method/pusher HTTP/1.1" 200 96 "http://localhost/shadiCo/item/146" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
  </code></pre>
  
  <p>Edited after use @elcodedocle Code : 
  The problem was not ajax or mysql problem , its get_headers() function problem which slow down the request which i use for check if image exists or not, by using this function :</p>
  
  <pre><code>public function url_exists($url) {
      if(!empty($url) &amp;&amp; $this-&gt;is_url($url) &amp;&amp; extension_loaded('openssl'))
      {              
              $file_headers = get_headers($url);
              if($file_headers[0] == 'HTTP/1.1 404 Not Found')
              {
                return false;
              }else{
  
                      $allowed = array('Content-Type: image/jpeg','Content-Type: image/pjpeg','Content-Type: image/png','Content-Type: image/gif');
  
                       if(!in_array($file_headers[1], $allowed))
                       {
                                      return false;
                       }else{
                                      return true;
                       }                     
               }  
     }else{
          return false;
     }
  }
  </code></pre>