CURLOPT_MAXAGE_CONN.3 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 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. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH CURLOPT_MAXAGE_CONN 3 "18 Apr 2019" libcurl libcurl
  26. .SH NAME
  27. CURLOPT_MAXAGE_CONN \- max idle time allowed for reusing a connection
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXAGE_CONN, long age);
  32. .fi
  33. .SH DESCRIPTION
  34. Pass a long as parameter containing \fIage\fP - the maximum time in seconds
  35. that you allow an existing connection to have been idle to be considered for
  36. reuse for this request.
  37. The "connection cache" that holds previously used connections. When a new
  38. request is to be done, it will consider any connection that matches for
  39. reuse. The \fICURLOPT_MAXAGE_CONN(3)\fP limit prevents libcurl from trying too
  40. old connections for reuse, since old connections have a high risk of not
  41. working and thus trying them is a performance loss and sometimes service loss
  42. due to the difficulties to figure out the situation. If a connection is found
  43. in the cache that is older than this set \fIage\fP, it will instead be closed.
  44. .SH DEFAULT
  45. Default maximum age is set to 118 seconds.
  46. .SH PROTOCOLS
  47. All
  48. .SH EXAMPLE
  49. .nf
  50. CURL *curl = curl_easy_init();
  51. if(curl) {
  52. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  53. /* only allow 30 seconds idle time */
  54. curl_easy_setopt(curl, CURLOPT_MAXAGE_CONN, 30L);
  55. curl_easy_perform(curl);
  56. }
  57. .fi
  58. .SH AVAILABILITY
  59. Added in 7.65.0
  60. .SH RETURN VALUE
  61. Returns CURLE_OK.
  62. .SH "SEE ALSO"
  63. .BR CURLOPT_TIMEOUT "(3), " CURLOPT_FORBID_REUSE "(3), "
  64. .BR CURLOPT_FRESH_CONNECT "(3), " CURLOPT_MAXLIFETIME_CONN "(3), "