Re: A question aboout Cache_HTTP_Request

From: Date: Thu, 28 Aug 2003 11:51:21 +0000
Subject: Re: A question aboout Cache_HTTP_Request
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-20742@lists.php.net to get a copy of this message
Alexey Borzov wrote:
require_once 'HTTP/Request.php'; // HTTP_Request has moronic redirect "handling", turn that off $req =& new HTTP_Request('http://www.example.com/somefile.html', array('allowRedirects' => false)); $req->addHeader('If-Modified-Since', $httpDate); $req->sendRequest(); if (304 == $req->getResponseCode()) { // get data from cache } else { // update cache }
That's more or less what I had to do externally. I consider this a bug (or at least a really urgent feature request) that Cache doesn't do this on its own, since it could easily abuse a remote server.
Of course I never said that HTTP_Request has functionality to generate this $httpDate itself. It is left as an exercise for the reader.
You should be able to use the cache file's modification time (filemtime()) for this. -- Marshall Roch

« previous php.pear.dev (#20742) next »