diff --git a/plugins/system/cache/cache.php b/plugins/system/cache/cache.php index 2c210c50cf5db..1b12e5d36d9c1 100644 --- a/plugins/system/cache/cache.php +++ b/plugins/system/cache/cache.php @@ -130,7 +130,7 @@ public function onAfterInitialise() $this->app->setBody($data); // Dumps HTML page. - echo $this->app->toString(); + echo $this->app->toString((bool) $this->app->get('gzip')); // Mark afterCache in debug and run debug onAfterRespond events. // e.g., show Joomla Debug Console if debug is active. @@ -146,25 +146,31 @@ public function onAfterInitialise() } /** - * After Route Event. + * After Render Event. * Verify if current page is not excluded from cache. * * @return void * - * @since 3.9.0 + * @since __DEPLOY_VERSION__ */ - public function onAfterRoute() + public function onAfterRender() { - if ($this->app->isClient('administrator') || $this->app->get('offline', '0') || count($this->app->getMessageQueue())) + if ($this->_cache->getCaching() === false) { return; } + // We need to check if user is guest again here, because auto-login plugins have not been fired before the first aid check. // Page is excluded if excluded in plugin settings. - if ($this->isExcluded()) + if (!JFactory::getUser()->get('guest') || count($this->app->getMessageQueue()) || $this->isExcluded() === true) { $this->_cache->setCaching(false); + + return; } + + // Disable compression before caching the page. + $this->app->set('gzip', false); } /** @@ -177,17 +183,13 @@ public function onAfterRoute() */ public function onAfterRespond() { - if ($this->app->isClient('administrator') || $this->app->get('offline', '0') || count($this->app->getMessageQueue())) + if ($this->_cache->getCaching() === false) { return; } - // We need to check if user is guest again here, because auto-login plugins have not been fired before the first aid check. - if (JFactory::getUser()->get('guest')) - { - // Saves current page in cache. - $this->_cache->store(null, $this->getCacheKey()); - } + // Saves current page in cache. + $this->_cache->store(null, $this->getCacheKey()); } /**