CURLOPT_MAXAGE_CONN.3 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 2019 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" **************************************************************************
  22. .\"
  23. .TH CURLOPT_MAXAGE_CONN 3 "18 Apr 2019" "libcurl 7.65.0" "curl_easy_setopt options"
  24. .SH NAME
  25. CURLOPT_MAXAGE_CONN \- max idle time allowed for reusing a connection
  26. .SH SYNOPSIS
  27. .nf
  28. #include <curl/curl.h>
  29. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXAGE_CONN, long maxage);
  30. .fi
  31. .SH DESCRIPTION
  32. Pass a long as parameter containing \fImaxage\fP - the maximum time in seconds
  33. that you allow an existing connection to have been idle to be considered for
  34. reuse for this request.
  35. The "connection cache" that holds previously used connections. When a new
  36. request is to be done, it will consider any connection that matches for
  37. reuse. The \fICURLOPT_MAXAGE_CONN(3)\fP limit prevents libcurl from trying too
  38. old connections for reuse, since old connections have a high risk of not
  39. working and thus trying them is a performance loss and sometimes service loss
  40. due to the difficulties to figure out the situation. If a connection is found
  41. in the cache that is older than this set \fImaxage\fP, it will instead be
  42. closed.
  43. .SH DEFAULT
  44. Default maxage is 118 seconds.
  45. .SH PROTOCOLS
  46. All
  47. .SH EXAMPLE
  48. .nf
  49. CURL *curl = curl_easy_init();
  50. if(curl) {
  51. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  52. /* only allow 30 seconds idle time */
  53. curl_easy_setopt(curl, CURLOPT_MAXAGE_CONN, 30L);
  54. curl_easy_perform(curl);
  55. }
  56. .fi
  57. .SH AVAILABILITY
  58. Added in 7.65.0
  59. .SH RETURN VALUE
  60. Returns CURLE_OK.
  61. .SH "SEE ALSO"
  62. .BR CURLOPT_TIMEOUT "(3), " CURLOPT_FORBID_REUSE "(3), "
  63. .BR CURLOPT_FRESH_CONNECT "(3), " CURLOPT_MAXLIFETIME_CONN "(3), "