12

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.

Ying-Shan Lin
  • 607
  • 5
  • 22
Riccardo Zorn
  • 5,590
  • 1
  • 20
  • 36
  • The users are logged-in or not? On both cases (conservative and progressive). – ilias Jan 18 '14 at 00:21
  • Not logged in, I think Joomla cache is disabled by design when users are logged in. – Riccardo Zorn Jan 18 '14 at 15:25
  • Yes, that's why I asked. I suppose you already have looked at this: [global module caching](http://www.inmotionhosting.com/support/edu/joomla-25/caching/global-module-caching) but I post it anyway just in case. – ilias Jan 18 '14 at 18:25
  • 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 Jan 19 '14 at 09:12
  • 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 Jan 21 '14 at 18:32
  • So this is your own module and your own component, nothing to do with anything in the core? – Elin Jan 21 '14 at 22:37
  • @dmi3y I'm testing on 2.5 and 3.2 now, it's intended for distribution so it should support both. Appending the userid would make the cache quite ineffective, and most likely it wouldn't work unless I added it explicitly in the query params. – Riccardo Zorn Jan 22 '14 at 09:47
  • @Elin: yes it's a package of a component, one module and 3 plugins (only the system one is involved in this issue though, the others are for authentication) – Riccardo Zorn Jan 22 '14 at 09:48

1 Answers1

0

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.

Elin
  • 6,507
  • 3
  • 25
  • 47
  • 1
    Thank you @Elin, but my modules are changing output based on user interaction, filters being set etc., not only changes in the underlying structure (for which I issue an appropriate cleanCache() already). I am the developer of the LittleHelper package which features a clean cache function, this is however defeating my purpose altogether: at this point it would be easier to force cache off as it wouldn't have the overhead of cleaning the cache... – Riccardo Zorn Jan 22 '14 at 09:44
  • I think that's the best idea for this case. – Elin Jan 22 '14 at 10:17