I'm currently debugging (and trying to understand why) the caching for the html view is created, but not for the xml view.

I read the Joomla! documentation article https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Adding_Cache and a similiar question in this portal 5 years ago: How can I use Joomla's Cache with my components view?

My controller.php looks like this:

public function display($cacheable = false, $urlparams = false)
    $cacheable = true;

    $viewName   = $this->input->get('view');
    $viewLayout = $this->input->get('layout', 'default');

    if (JFactory::getUser()->get('id') || !in_array($viewName, array('html', 'xml')) || $viewLayout == 'xsl') {
        $cacheable = false;

    $document = JFactory::getDocument();
    $viewType = $document->getType();

    $view = $this->getView($viewName, $viewType, '', array('base_path' => $this->basePath, 'layout' => $viewLayout));

    $view->setModel($this->getModel('Sitemap'), true);

    $safeurlparams = array(
        'id' => 'INT',
        'itemid' => 'INT',
        'uid' => 'CMD',
        'action' => 'CMD',
        'property' => 'CMD',
        'value' => 'CMD',
        'view' => 'CMD',
        'lang' => 'CMD'

    return parent::display($cacheable, $safeurlparams);

Folder structure:
- com_my_extension
--- views
---- html
---- xml

What I am missing here?

Is it that the standard Joomla! cache, doesn't cache the XML output and I have to do it manually?

Or is the data in $safeurlparams wrong? (I don't totally understand how the parts in this array should be.)

1 Answer 1



An older question, but may give you a direction to consider to figure out what to add into the code generating your XML.

  • Thx for the link. If I interpret it right, the html view is automatically created with the controller display cachable true statement, but for XML I have to implement it on my own.
    – svanschu
    Commented Jun 16, 2020 at 19:10
  • 1
    I think that sounds about right. I'm in the process of figuring out how various Joomla framework parts work currently, so if I find a different way of doing it, I'll comment back. Commented Jun 16, 2020 at 23:33
  • little more research. The cache should be made with the existing code. Something is preventing the cache file to be created for the second view. Still debugging which part is the barrier.
    – svanschu
    Commented Jun 19, 2020 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.