Example #1
0
 /**
  * Is there a valid cache file we can use
  *
  * @return bool
  */
 protected function getCacheFile()
 {
     $dir = $this->temp_dir . DIRECTORY_SEPARATOR . 'synergy';
     $file = $dir . DIRECTORY_SEPARATOR . md5($this->request->getUri()) . '.syn';
     if ($this->useGzip() && file_exists($file . '.gz') && date('U') - filemtime($file . '.gz') < $this->cache_expire) {
         if (!headers_sent()) {
             header('Content-Encoding: gzip');
             header('X-Synergy-Cache: ' . basename($file . '.gz'));
         }
         readfile($file . '.gz');
         return true;
     } elseif (file_exists($file) && date('U') - filemtime($file) < $this->cache_expire) {
         if (!headers_sent()) {
             header('X-Synergy-Cache: ' . basename($file));
             header('X-Synergy-Cached: ' . date('Y/m/d H:i:s', filemtime($file)));
         }
         readfile($file);
         return true;
     }
     return false;
 }