Re: A question aboout Cache_HTTP_Request
| From: | Alexey Borzov | Date: | Thu, 28 Aug 2003 11:24:51 +0000 |
| Subject: | Re: A question aboout Cache_HTTP_Request | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-20740@lists.php.net to get a copy of this message | ||
Hi!
Marshall Roch wrote:
You could do a conditional GET. The cache would send headers asking if the content is still the same (same ETag and Last-Modified headers returned by server), and if not, it would download the file. The cache would have to remember the ETag and the Last-Modified headers (which could be the write time of the cache file). I don't know if Cache stores this information already, but it definitely should. Alexey Borzov said in the HTTP_Status discussion that HTTP_Request is quite capable of sending conditional GETs. Maybe he can help figure out how to impliment this.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 } Of course I never said that HTTP_Request has functionality to generate this $httpDate itself. It is left as an exercise for the reader.