CURLOPT_CA_CACHE_TIMEOUT(3)
π CURLOPT_CA_CACHE_TIMEOUT(3) β like, the whole glow-up guide
okay bestie, welcome to the Library Functions Manual, pull up a chair, we're talking about CURLOPT_CA_CACHE_TIMEOUT and honestly? it's giving "unsung hero of your TLS handshakes" β¨
πΈ NAME πΈ
CURLOPT_CA_CACHE_TIMEOUT β the life-time for cached certificate stores. yes queen, it's literally the expiration date on libcurl's memory of your CA certs π
β¨ SYNOPSIS β¨
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CA_CACHE_TIMEOUT, long age);
π DESCRIPTION π
so you pass a long, right? and that's your timeout in seconds. what it's telling libcurl is: this is the maximum time any cached CA certificate store it's holding in memory may be kept and reused for new connections. once that timeout has expired, a subsequent fetch that needs a CA certificate has to go reload it. no shortcuts, no leftovers, periodt π
building a CA certificate store from a CURLOPT_CAINFO(3) file is a slow operation (like, painfully slow, an actual vibe killer π) so curl may cache the generated certificate store internally to speed up future connections. iconic behavior honestly.
now the important bits, don't skip these:
- set the timeout to zero to completely disable caching (no cache, no crumbs)
- set it to
-1to retain the cached store forever (forever-ever π₯) - by default, libcurl caches this info for 24 hours
π¦ DEFAULT π¦
86400 (24 hours) β that's the factory setting bb, no cap β
π PROTOCOLS π
this functionality affects all TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. all of them. the whole squad π«Ά
heads up though: this option works only with the following TLS backends: GnuTLS, OpenSSL, Schannel and wolfSSL. if your backend isn't on the list, this option is lowkey just not the moment π
π EXAMPLE π
ok so here's the little demo, keep it exactly as is:
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
/* only reuse certificate stores for a short time */
curl_easy_setopt(curl, CURLOPT_CA_CACHE_TIMEOUT, 60L);
res = curl_easy_perform(curl);
/* in this second request, the cache is not used if more than
sixty seconds passed since the previous connection */
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
}
see how that works? sixty seconds and the cache is like "mmm I'm out" π
π§ HISTORY π§
this option is supported by:
- OpenSSL and its forks β since
7.87.0 - Schannel β since
8.5.0 - wolfSSL β since
8.9.0 - GnuTLS β since
8.9.0
look at them all arriving fashionably late to the party, we love a staggered rollout π
π AVAILABILITY π
added in curl 7.87.0 β she's not ancient, she's vintage β¨
β RETURN VALUE β
curl_easy_setopt(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK. non-zero means an error occurred β go check libcurl-errors(3) and don't come for me about it π
π₯ SEE ALSO π₯
CURLOPT_CAINFO(3)CURLOPT_CAINFO_BLOB(3)CURLOPT_CAPATH(3)CURLOPT_SSL_VERIFYHOST(3)CURLOPT_SSL_VERIFYPEER(3)
okay that's the whole page, you ate that fr fr π
this lil number lives in libcurl, dated 2026-10-12, filed under CURLOPT_CA_CACHE_TIMEOUT(3) β mwah, go forth and cache responsibly ππ
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms