cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Using CURLOPT_TIMECONDITION

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Fri, 12 Dec 2003 16:38:37 +0100 (CET)

On Thu, 11 Dec 2003, DOMINICK C MEGLIO wrote:

> Can someone explain to me how I use CURLOPT_TIMECONDITION/CURLOPT_TIMEVALUE
> (I couldn't seem to find an example).

You set a condition you want to use with TIMECONDITION, and then you set the
corresponding time with TIMEVALUE.

> Am I right in assuming this can be used for caching?

It can be used to only retrieve remote documents that have been modified since
a given time, or not modified since that time.

> I.e. if the version on the server is the same as on disk, simply load from
> disk?

Yes, you can use it for that.

> That's what I'm trying to do. I think I understand what I set those options
> too, my question is, when I call curl_easy_perform is there an error code
> that is something like "file on server is same or older than on disk" or
> something so that I know to load it from disk?

libcurl doesn't help you all the way with this, you need to fetch the HTTP
response code and if you got a 304 back, it means that the timecondition
didn't evaluate true.

So, if you ask for "If-Modified-Since" and use a time of your local file, you
will get a 200 and the updated file if it is newer on the server, or you'll
get a 304 back if the file on the server is not newer than your local one.

-- 
    Daniel Stenberg -- http://curl.haxx.se/ -- http://daniel.haxx.se/
   [[ Do not send mails to this email address. They won't reach me. ]]
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
Received on 2003-12-12