cURL / Mailing Lists / curl-library / Single Mail


cache in libcurl

From: fine cur <>
Date: Thu, 22 Feb 2007 15:49:59 -0800 (PST)

Hi everyone:
  I use libcurl to load image from URL. Here is my code. I found that when I ran the program twice with the same URL, the speed is almost the same, which means there is no cache at all. I have expected that libcurl can do the same cache as IE so when I load the same image the second time, it will load from local cache. Did I miss something?
  Thank you very much
  ImagePointer * readImageFromURL(char* url)
  CURL *curl_handle;
 struct MemoryStruct chunk;
   chunk.memory=NULL; /* we expect realloc(NULL, size) to work */
 chunk.size = 0; /* no data at this point */
 /* init the curl session */
 curl_handle = curl_easy_init();
 /* specify URL to get */
 curl_easy_setopt(curl_handle, CURLOPT_URL, url);
 /* send all data to this function */
 curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, writeMemoryCallback);
 /* we pass our 'chunk' struct to the callback function */
 curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
 /* some servers don't like requests that are made without a user-agent
     field, so we provide one */
 curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
   /* get it! */
 /* cleanup curl stuff */
  //make image from chunk.memory
  ptr = //...
 return ptr;

Check out the all-new Yahoo! Mail beta - Fire up a more powerful email and get things done faster.
Received on 2007-02-23