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:
components
- 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.)