CURLOPT_DN...OBAL_CACHE(3)
π NAME π
CURLOPT_DNS_USE_GLOBAL_CACHE β the global DNS cache situation, aka the fossil you should absolutely not be touching π
(this one lives in the Library Functions Manual, bestie β hi, welcome, come sit with me β¨)
πΈ SYNOPSIS πΈ
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_USE_GLOBAL_CACHE,
long enable);
π¦ DESCRIPTION π¦
Okay so first things first, and I need you to hear me on this: it has no function since 7.62.0. Do not use. Like, at all. It's giving haunted artifact in the attic. π
You pass it a long. Back in the day, if the enable value was 1, it told curl to use a global DNS cache that survives between easy handle creations and deletions. Cute in theory! But nope β this is not thread-safe and it uses a global variable, which is exactly the kind of chaos that makes your future self cry at 3am π
So if you actually want to share a DNS cache between transfers, the correct slay is CURLOPT_SHARE(3) and curl_share_init(3). Use those. They ate. π
π DEFAULT π
0
π PROTOCOLS π
This functionality affects all supported protocols β every single one, no cap β¨
π§ EXAMPLE π§
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
/* switch off the use of a global, thread-unsafe, cache */
curl_easy_setopt(curl, CURLOPT_DNS_USE_GLOBAL_CACHE, 0L);
result = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
}
See how they set it to 0L? That's the move β turning the thread-unsafe global cache off. Iconic behaviour, no notes π
π DEPRECATED π
Deprecated since 7.11.1. Functionality removed in 7.62.0.
Yeah. It's been deprecated longer than some of us have been alive, and the whole feature got yeeted in 7.62.0. It's literally a ghost option now π»
β AVAILABILITY β
Added in curl 7.9.3 β a true elder of the library π«Ά
π 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 β check out
libcurl-errors(3)for the deets
π₯ SEE ALSO π₯
That's the whole vibe check, bestie β this page is from libcurl, dated 2026-10-12. Stay safe, don't use the global cache, and go touch some shared memory instead ππ¦β¨
π¦ 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