Skip to content

Performance: reuse cURL connections

jaapjansma requested to merge github/fork/ewandennis/curl-conn-reuse into master

Created by: ewandennis

This PR holds a cURL session open so it can reuse connections. The effect is to amortise connection setup cost across HTTP requests to the same host.

Changes:

  • renamed cURL session var $ch to $curl_session
  • moved $curl_session into a static class variable (self::$curl_session)
  • Conditionally create $curl_session on first use
  • Remove call to curl_close() to enable session reuse
  • Call sparkpost_log() to report on total call time for each request

Merge request reports