Skip to main content
Notice removed Draw attention by CommunityBot
Bounty Ended with no winning answer by CommunityBot
Notice added Draw attention by jdog
Bounty Started worth 50 reputation by jdog
added 99 characters in body
Source Link
Lodder
  • 26.9k
  • 3
  • 48
  • 94
  1. With a debugger, the debugger stops in any plugin I try, but not in the cache plugin

  2. Under Administrator->Extensions->Manage I can find the Cache plugin installed

  3. Under Administrator->Extensions->Discover, it is now found.

  4. 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"

  5. 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(); }

     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 );
     }
    

    private function setCacheHeaders() { JApplicationWeb::setHeader( 'Cache-Control', 'public, max-age=10800', true ); JApplicationWeb::setHeader( 'Vary', 'Cookie', true ); JApplicationWeb::setHeader( 'Pragma', '', true ); }

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->cacheableJApplicationWeb::getInstance->response->cacheable is false again.

  1. With a debugger, the debugger stops in any plugin I try, but not in the cache plugin

  2. Under Administrator->Extensions->Manage I can find the Cache plugin installed

  3. Under Administrator->Extensions->Discover, it is now found.

  4. 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"

  5. 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 ); }

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.

  1. With a debugger, the debugger stops in any plugin I try, but not in the cache plugin

  2. Under Administrator->Extensions->Manage I can find the Cache plugin installed

  3. Under Administrator->Extensions->Discover, it is now found.

  4. 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"

  5. 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 );
     }
    

    }

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.

Source Link
jdog
  • 953
  • 6
  • 18

Can't turn on cache in 3.4.4

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';
  1. Administrator->Extensions->Plugins->Page Caching is enabled

In the plugin, Browser Caching is enabled

  1. With a debugger, the debugger stops in any plugin I try, but not in the cache plugin

  2. Under Administrator->Extensions->Manage I can find the Cache plugin installed

  3. Under Administrator->Extensions->Discover, it is now found.

  4. 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"

  5. 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?