JPATH_BASE.DS.'cache', 'defaultgroup' => 'page', 'lifetime' => $this->params->get('cachetime', 15) * 60, 'browsercache' => $this->params->get('browsercache', false), 'caching' => false, 'language' => $config->getValue('config.language', 'en-GB') ); jimport('joomla.cache.cache'); $this->_cache =& JCache::getInstance( 'page', $options ); if (!$user->get('aid') && $_SERVER['REQUEST_METHOD'] == 'GET') { $this->_cache->setCaching(true); } } /** * Converting the site URL to fit to the HTTP request * */ function onAfterInitialise() { global $mainframe, $_PROFILER; if($mainframe->isAdmin() || JDEBUG) { return; } $data = $this->_cache->get(); if($data !== false) { // the following code searches for a token in the cached page and replaces it with the // proper token. $user = &JFactory::getUser(); $token = JUtility::getToken(); $search = '##'; $replacement = ''; $data = preg_replace( $search, $replacement, $data ); JResponse::setBody($data); echo JResponse::toString($mainframe->getCfg('gzip')); if(JDEBUG) { $_PROFILER->mark('afterCache'); echo implode( '', $_PROFILER->getBuffer()); } $mainframe->close(); } } function onAfterRender() { global $mainframe; if($mainframe->isAdmin() || JDEBUG) { return; } $this->_cache->store(); } }