title: Php SoapClient is very slow on first connection
body: <p>I use php <code>SoapClient</code> to call M3 (Movex) webservices, stored on our internal server. My Symfony 3.4 project which does the calls is on another internal linux server.</p>
  
  <p>I noticed that the initialization of the soap client is very slow (2-3 minutes) when it's done <strong>after a long time without using it</strong> (several hours). For example, it occurs the morning, when I test my project for the first time of the day. But I have no problem for every initializations and calls done after several minutes (responds in 500ms).</p>
  
  <p>Because of the 1st init takes several minutes, my nginx server returns a 504 gateway time-out error after 1 minute.</p>
  
  <p>The webservices urls are in HTTPS and we use SSL certificates. We also had to authenticate with a login and a password. I use a session cookie, available for 8 hours, that I add in the HTTP request header. We don't use a proxy.</p>
  
  <p>I think it's a <strong>cache problem</strong>. When I'm using SoapUI, I don't have the problem, the webservice responds very fastly.</p>
  
  <p>Here is the configuration of the soap extension in my php.ini :</p>
  
  <p><a href="https://i.stack.imgur.com/1vGvs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1vGvs.png" alt="enter image description here"></a></p>
  
  <p>Here is my soap client init :</p>
  
  <pre><code>$client = new SoapClient("https://my-domain.com:55080/my-webservice?wsdl", array(
    'login'     =&gt; $login,
    'password'  =&gt; $pwd,
    'trace'     =&gt; true,
    'exceptions' =&gt; true,
    'stream_context' =&gt; stream_context_create(array(
      'http' =&gt; ['header' =&gt; 'cookie: ' . $cookie]
    ))
  ));
  </code></pre>
  
  <p>I tried to add <code>'cache_wsdl' =&gt; WSDL_CACHE_MEMORY</code> in the options but it's worse, every time I'm using it, it's very slow.</p>
  
  <p>Here are the logs to see where the problem occurs (look at lines 3 and 4 -> 2 minutes) :</p>
  
  <pre><code>01/10/19 09:58:06 ------- Get Customer -------
  01/10/19 09:58:06 - Cookie exists -&gt; send it in the request
  01/10/19 09:58:06 - BEGIN Init soap client
  01/10/19 10:00:07 - END Init soap client
  01/10/19 10:00:07 - BEGIN client-&gt;GetCustomerData
  01/10/19 10:00:07 - END client-&gt;GetCustomerData
  01/10/19 10:00:07 ------- END Get Customer -------
  </code></pre>
  
  <p>When I test it again after several minutes (no problem, done in the same second) :</p>
  
  <pre><code>01/10/19 10:03:52 ------- Get Customer -------
  01/10/19 10:03:52 - Cookie exists -&gt; send it in the request
  01/10/19 10:03:52 - BEGIN Init soap client
  01/10/19 10:03:52 - END Init soap client
  01/10/19 10:03:52 - BEGIN client-&gt;GetCustomerData
  01/10/19 10:03:52 - END client-&gt;GetCustomerData
  01/10/19 10:03:52 ------- END Get Customer -------
  </code></pre>