CURLOPT_MAXAGE_CONN.3 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. .\" generated by cd2nroff 0.1 from CURLOPT_MAXAGE_CONN.md
  2. .TH CURLOPT_MAXAGE_CONN 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_MAXAGE_CONN \- max idle time allowed for reusing a connection
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXAGE_CONN, long age);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long as parameter containing \fIage\fP \- the maximum time in seconds
  12. allowed for an existing connection to have been idle to be considered for
  13. reuse for this request.
  14. The "connection cache" holds previously used connections. When a new request
  15. is to be done, libcurl considers any connection that matches for reuse. The
  16. \fICURLOPT_MAXAGE_CONN(3)\fP limit prevents libcurl from trying too old
  17. connections for reuse, since old connections have a higher risk of not working
  18. and thus trying them is a performance loss and sometimes service loss due to
  19. the difficulties to figure out the situation. If a connection is found in the
  20. cache that is older than this set \fIage\fP, it is closed instead.
  21. .SH DEFAULT
  22. 118 seconds
  23. .SH PROTOCOLS
  24. This functionality affects all supported protocols
  25. .SH EXAMPLE
  26. .nf
  27. int main(void)
  28. {
  29. CURL *curl = curl_easy_init();
  30. if(curl) {
  31. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  32. /* only allow 30 seconds idle time */
  33. curl_easy_setopt(curl, CURLOPT_MAXAGE_CONN, 30L);
  34. curl_easy_perform(curl);
  35. }
  36. }
  37. .fi
  38. .SH AVAILABILITY
  39. Added in curl 7.65.0
  40. .SH RETURN VALUE
  41. Returns CURLE_OK.
  42. .SH SEE ALSO
  43. .BR CURLOPT_FORBID_REUSE (3),
  44. .BR CURLOPT_FRESH_CONNECT (3),
  45. .BR CURLOPT_MAXLIFETIME_CONN (3),
  46. .BR CURLOPT_TIMEOUT (3)