12
votes

I have a module which allows the user to choose a category, which is then used for filtering the component's output. So when the user first clicks on the menu item, the view shows items from all categories, then as they click on the module, a param such as &catid=69 etc. is added to the url and used to filter the items displayed.

A system plugin complements the behaviour by registering the extra 'catid' param i.e.

$registeredurlparams->catid = 'INT';
$app->set('registeredurlparams', $registeredurlparams); 

The module uses the category id to create the cache id, and shows the top-level categories + the subcategories of the category that was chosen.

This works fine with both conservative cache enabled in the system configuration and the System Cache plugin enabled.

My concern is that I cannot get it to work with progressive cache: even though the component output is cached correctly, the module doesn't get updated (so I never see the subcategories).

Eventually I plan to make the extension available on the JED, and I'd like to be compatible with all possible cache configurations. Is there any possibility to force the progressive cache to add the parameters I want to the cache id?

Workarounds such as sending the full category tree and doing it with ajax will not be accepted.

1
The users are logged-in or not? On both cases (conservative and progressive). - ilias
Not logged in, I think Joomla cache is disabled by design when users are logged in. - Riccardo Zorn
Yes, that's why I asked. I suppose you already have looked at this: global module caching but I post it anyway just in case. - ilias
yes, I read it, it just states that individual module cache is not taken into consideration with Progressive caching. But since progressive caching allows different versions of the component output on the same Itemid, I'm hopeful it's possible to extend the same behaviour to modules without core hacks - Riccardo Zorn
which version of Joomla do you have? that sounds to me like bug. you mentioned that module's code handles creation of cache id, if you could do append user id in there in addition of category + subcategory? - dmi3y

1 Answers

0
votes

One thing you could look at is ContentModelArticle in the back end. You will notice that cleanCache() forcibly clears the content modules that could be impacted by a save or create.

protected function cleanCache($group = null, $client_id = 0)
{
    parent::cleanCache('com_content');
    parent::cleanCache('mod_articles_archive');
    parent::cleanCache('mod_articles_categories');
    parent::cleanCache('mod_articles_category');
    parent::cleanCache('mod_articles_latest');
    parent::cleanCache('mod_articles_news');
    parent::cleanCache('mod_articles_popular');
}

I've always thought this was a sledge hammer/kludge since it doesn't let the webmaster control whether or not to do this, but you could do something along the lines of making a custom cleanCache() for your model.