I'm using PHP cURL module to extract timestamp of a remote file via HTTP headers. I've managed to grab modification timestamp by using CURLOPT_FILETIME
constant. Of course, I'm doing this in order too see if the remote file has changed without downloading it's contents.
$ch = curl_init($url); /* create URL handler */
curl_setopt($ch, CURLOPT_NOBODY, TRUE); /* don't retrieve body contents */
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); /* follow redirects */
curl_setopt($ch, CURLOPT_HEADER, FALSE); /* retrieve last modification time */
curl_setopt($ch, CURLOPT_FILETIME, TRUE); /* get timestamp */
$res = curl_exec($ch);
$timestamp = curl_getinfo($ch, CURLINFO_FILETIME);
curl_close($ch);
What is, in your opinion the best way to check if remote file has changed? Should I go with timestamp check only? Or are there some other clever options that didn't came to my mind?!