1CURLOPT_MAXAGE_CONN(3)     curl_easy_setopt options     CURLOPT_MAXAGE_CONN(3)
2
3
4

NAME

6       CURLOPT_MAXAGE_CONN - max idle time allowed for reusing a connection
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXAGE_CONN, long age);
12

DESCRIPTION

14       Pass  a  long as parameter containing age - the maximum time in seconds
15       that you allow an existing connection to have been idle to  be  consid‐
16       ered for reuse for this request.
17
18       The  "connection  cache" that holds previously used connections. When a
19       new request is to be done, it will consider any connection that matches
20       for  reuse. The CURLOPT_MAXAGE_CONN(3) limit prevents libcurl from try‐
21       ing too old connections for reuse, since old connections  have  a  high
22       risk  of  not  working  and  thus trying them is a performance loss and
23       sometimes service loss due to the difficulties to figure out the situa‐
24       tion. If a connection is found in the cache that is older than this set
25       age, it will instead be closed.
26

DEFAULT

28       Default maximum age is set to 118 seconds.
29

PROTOCOLS

31       All
32

EXAMPLE

34       CURL *curl = curl_easy_init();
35       if(curl) {
36         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
37
38         /* only allow 30 seconds idle time */
39         curl_easy_setopt(curl, CURLOPT_MAXAGE_CONN, 30L);
40
41         curl_easy_perform(curl);
42       }
43

AVAILABILITY

45       Added in 7.65.0
46

RETURN VALUE

48       Returns CURLE_OK.
49

SEE ALSO

51       CURLOPT_TIMEOUT(3), CURLOPT_FORBID_REUSE(3),  CURLOPT_FRESH_CONNECT(3),
52       CURLOPT_MAXLIFETIME_CONN(3),
53
54
55
56libcurl 8.0.1                  January 02, 2023         CURLOPT_MAXAGE_CONN(3)
Impressum