I have a complex install of Joomla 3.4.4 with jSeblod and many other extensions. We are planning to use Varnish4 in front of the web server and because of that need to turn on proper Cache-Control headers.
But I cannot seem to turn on caching. Here is what I have tried:
1)
configuration.php
public $caching = '1';
public $cache_handler = 'file';
public $cachetime = '30';
2) Administrator->Extensions->Plugins->Page Caching is enabled
In the plugin, Browser Caching is enabled
3) With a debugger, the debugger stops in any plugin I try, but not in the cache plugin
4) Under Administrator->Extensions->Manage I can find the Cache plugin installed
5) Under Administrator->Extensions->Discover, it is now found.
6) On my own live website I get the same results, however the Cache header is "Cache-Control: no-cache" instead of "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
7) I have built a plugin which turns the cache on just before the Response is sent:
class plgSystemGtnocachies extends JPlugin
{
function plgSystemGtnocachies( &$subject, $config )
{
parent::__construct( $subject, $config );
}
function __destruct()
{
if (!headers_sent())
{
$this->setCacheHeaders();
}
}
public function onAfterRender()
{
JApplicationWeb::allowCache( true );
$this->setCacheHeaders();
}
private function setCacheHeaders()
{
JApplicationWeb::setHeader( 'Cache-Control', 'public, max-age=10800', true );
JApplicationWeb::setHeader( 'Vary', 'Cookie', true );
JApplicationWeb::setHeader( 'Pragma', '', true );
}
}
What I find however is that when the function call returns to
class JEventDispatcher extends JObject
{
public function trigger($event, $args = array())
{
$result = array();
/*
* If no arguments were passed, we still need to pass an empty array to
* the call_user_func_array function.
*/
$args = (array) $args;
$event = strtolower($event);
// Check if any plugins are attached to the event.
if (!isset($this->_methods[$event]) || empty($this->_methods[$event]))
{
// No Plugins Associated To Event!
return $result;
}
// Loop through all plugins having a method matching our event
foreach ($this->_methods[$event] as $key)
{
// Check if the plugin is present.
if (!isset($this->_observers[$key]))
{
continue;
}
// Fire the event for an object based observer.
if (is_object($this->_observers[$key]))
{
$args['event'] = $event;
$value = $this->_observers[$key]->update($args);
------->
}
// Fire the event for a function based observer.
elseif (is_array($this->_observers[$key]))
{
$value = call_user_func_array($this->_observers[$key]['handler'], $args);
}
if (isset($value))
{
$result[] = $value;
}
}
return $result;
}
JApplicationWeb::getInstance->response->cacheable
is false again.
Any idea what is going on here?