Skip to content

Commit

Permalink
Disable gzip before caching the page
Browse files Browse the repository at this point in the history
  • Loading branch information
SharkyKZ committed Aug 12, 2019
1 parent 9cfec00 commit ae11474
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions plugins/system/cache/cache.php
Expand Up @@ -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.
Expand All @@ -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);
}

/**
Expand All @@ -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());
}

/**
Expand Down

0 comments on commit ae11474

Please sign in to comment.