/** * Renders content to the browsers. * If the clients cache isn't modified, it shouldn't send anything * @access public * @param $content * @param $compress * @return void */ public function render($use_cache = true) { // Is the client's browser cache valid? $cache = $this->cache->valid($this->headers['Last-Modified'], $this->headers['ETag']); // Cache is still fresh if ($cache === true and $use_cache === true) { header('HTTP/1.1 304 Not Modified'); exit; } // Send it all to the browser $this->send_headers(); echo $this->output; exit; }
/** * Renders content to the browsers. * If the clients cache isn't modified, it shouldn't send anything * @access public * @param $use_cache boolean Use the browsers cache to determine if we should send the content * @return void */ public function render($use_cache = true) { // Is the browser cache still valid? $cache_valid = $this->cache->valid($this->headers['Last-Modified'], $this->headers['ETag']); if ($cache_valid and $use_cache) { $this->status = 304; $this->headers = array(); $this->send_headers(); exit; } $this->send_headers(); echo $this->output; exit; }
/** * @depends test_CurrentModified_OldEtag */ public function testValidCache() { $_SERVER['HTTP_IF_MODIFIED_SINCE'] = strtotime(10); $_SERVER['HTTP_IF_NONE_MATCH'] = 'foo'; // Cache should be valid as the headers match $cache = new Scaffold_Response_Cache(); $valid = $cache->valid(strtotime(10), 'foo'); $this->assertTrue($valid); }