Persistent/keepalive HTTP with the PHP Curl library?

cURL PHP documentation (curl_setopt) says:

CURLOPT_FORBID_REUSETRUE to force
the connection to explicitly close
when it has finished processing, and
not be pooled for reuse.

So:

  1. Yes, actually it should re-use connections by default, as long as you re-use the cURL handle.
  2. by default, cURL handles persistent connections by itself; should you need some special headers, check CURLOPT_HTTPHEADER
  3. the server may send a keep-alive timeout (with default Apache install, it is 15 seconds or 100 requests, whichever comes first) – but cURL will just open another connection when that happens.

Leave a Comment