public function _serve_from_cache() { // Check the expiry time in the request headers and just return // Not Modified if appropriate if ($this->expiry_time) { expires::check($this->expiry_time); } // If caching is turned on and we're using Kohana's cache library ... if ($this->cache and !$this->cache_config_writes_to_docroot()) { // Get cache id (calling this cache_id() method if it's not already set) $cache_id = isset($this->cache_id) ? $this->cache_id : ($this->cache_id = $this->cache_id()); // Try to retrive it from the cache $content = $this->cache_instance()->get($cache_id); if (!empty($content)) { // Serve the cached content ... echo $content; // ... run the shutdown events Kohana::shutdown(); // ... and bail out exit; } } // Add handler to cache the output (we check whether caching is // turned on at the final moment) Event::add('system.display', array($this, '_cache_output')); }
* * ---------------------------------------------------------------------------- */ // Define the name of the front controller index define('FCINDEX', basename(__FILE__)); // Define the absolute paths for configured directories define('DOCROOT', str_replace('\\', '/', realpath(getcwd())) . '/'); define('APPPATH', str_replace('\\', '/', realpath($application)) . '/'); define('MODPATH', str_replace('\\', '/', realpath($modules)) . '/'); define('SYSPATH', str_replace('\\', '/', realpath($system)) . '/'); // Clean up the configuration vars unset($application, $modules, $system); if (file_exists('install' . EXT)) { // Load the installation check return include 'install' . EXT; } // Load the main Kohana class require SYSPATH . 'classes/kohana' . EXT; // Enable auto-loading of classes spl_autoload_register(array('Kohana', 'auto_load')); // Enable the exception handler // set_exception_handler(array('Kohana', 'exception_handler')); // Enable the error-to-exception handler set_error_handler(array('Kohana', 'error_handler')); // Initialize the environment Kohana::init(); // Create the main instance Kohana::instance(); // Shutdown the environment Kohana::shutdown();