Actually, I have two questions.
(1) Is there a reduction in processing power or bandwidth used on the remote server if I get only the headers and not a full page search using php and curl?
(2) As I think, and I may be wrong, this answer to the first questions is YES, I try to get the last modified date or If-Modified-Since header of the deleted file just to compare it with the -date time of the locally stored data. so I can, if it has been modified, save it locally. However, my script seems unable to get this piece of information, I get NULL
when I run this:
class last_change { public last_change; function set_last_change() { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "http://url/file.xml"); curl_setopt($curl, CURLOPT_HEADER, true); curl_setopt($curl, CURLOPT_FILETIME, true); curl_setopt($curl, CURLOPT_NOBODY, true); // $header = curl_exec($curl); $this -> last_change = curl_getinfo($header); curl_close($curl); } function get_last_change() { return $this -> last_change['datetime']; // I have tested with Last-Modified & If-Modified-Since to no avail } }
If $header = curl_exec($curl)
not executed, the header data is displayed, even if I did not request it and looks like this:
HTTP/1.1 200 OK Date: Fri, 04 Sep 2009 12:15:51 GMT Server: Apache/2.2.8 (Linux/SUSE) Last-Modified: Thu, 03 Sep 2009 12:46:54 GMT ETag: "198054-118c-472abc735ab80" Accept-Ranges: bytes Content-Length: 4492 Content-Type: text/xml
Based on this, "Last-Modified" is returned.
So what am I doing wrong?
php curl header
Krule Sep 04 '09 at 12:26 2009-09-04 12:26
source share