bug
avatar AndySDH
AndySDH
29 Mar 2021

Something that always bothered me in Joomla, but never reported...

And I did a thorough google search and it looks nobody reported this before either.

When using Joomla Cache, even the documentation says:
https://docs.joomla.org/Cache

If you edit and save that article, and then refresh the site page you will find that the site displays the updated text this time. This is because whenever the edit is saved, Joomla clears the cache for that article.

Which is indeed what you would expect and what would make sense. When you save an article (or a contact, or any other item from any component), only the cache for THAT item (that ID) should be cleared.

Except this is not what happens. When you save an article, the cache for the WHOLE com_content component is cleared. The cache for EVERY article is cleared any time you save one article. And this happens for every component, not just for content.

I'm not sure why this is the case, as this seems a very unoptimized behavior that kinda defeats the purpose of caching in the first place, if you lose warmed cache for all content just for saving 1 article.

Even the documentation states that it should only clear that 1 article, but the documented text is not what actually happens.

Anyone has their two cents to share about this? Should this be addressed? Probably it should?

avatar AndySDH AndySDH - open - 29 Mar 2021
avatar AndySDH AndySDH - change - 29 Mar 2021
The description was changed
avatar AndySDH AndySDH - edited - 29 Mar 2021
avatar AndySDH AndySDH - change - 29 Mar 2021
The description was changed
avatar AndySDH AndySDH - edited - 29 Mar 2021
avatar AndySDH AndySDH - change - 29 Mar 2021
The description was changed
avatar AndySDH AndySDH - edited - 29 Mar 2021
avatar Fedik
Fedik - comment - 29 Mar 2021

I think it is valid issue.
However I do not see an easy way to fix it.
Currently we have cache stored per $option, and $key based on $app->registeredurlparams

{
/** @var \JCacheControllerView $cache */
$cache = \JFactory::getCache($option, 'view');
$cache->get($view, 'display');
}

That does not allow us to distinct the cache per Article, at least I do not see how.
Maybe someone have better knowledge about this part.

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

ok think about this. An article can be cached as

  • A Single Article View
  • A Blog Category Menu Item page
  • A list of articles in a table list view
  • etc

So flushing the cache of JUST the article is not going to be enough to clear your site of old cached versions. The whole com_content cache needs clearing.

avatar AndySDH
AndySDH - comment - 31 Mar 2021

The whole com_content cache needs clearing.

No it doesn't. Think about a site with 10.000 articles. Or 50.000 articles. Do you want to clear the whole cache every time you save 1 article? That defeats the purpose of cache in the first place.

According to what you've brought up, if someone is a smart developer, what should be said instead is:

  • Clear article ID
  • Clear category that the article belongs to

That's it

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

Joomla doesn't cache per article or per category. It caches views.

avatar AndySDH
AndySDH - comment - 31 Mar 2021

Joomla doesn't cache per article or per category. It caches views.

Well, and that's the purpose of this issue. Doing it that way with no tracking of IDs is clearly bad / unoptimized, since it causes the issue that I brought up in this OP.

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

Well, and that's the purpose of this issue. Doing it that way with no idea of IDs is clearly bad / unoptimized, since it causes the issue that I brought up in this OP.

So what you are requesting is a complete overhaul of the caching system that Joomla has used for a decade...

Joomla 4 will clear all these caches on saving an article. Gulp.

		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');
avatar AndySDH
AndySDH - comment - 31 Mar 2021

So what you are requesting is a complete overhaul of the caching system that Joomla has used for a decade...

I had/have no idea of the underlying code. Just bringing up an issue. No idea how hard or easy it is to change.

Joomla 4 will clear all these caches on saving an article. Gulp.

Gulp indeed.

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

To be clear - Im not defending how it is, its clearly not optimised for continuous editing on a live site - you have identified that and many before you have. The large sites I manage all do caching architecturally (on a load balancer or redis backed store) before even getting to Joomla, on a page basis too.

But basically its a huge job to refactor the caching layer to stop caching per "page" and start caching based on the "object cache" (where content is just an object) - certainly nothing is going to change fast here.

avatar AndySDH
AndySDH - comment - 31 Mar 2021

Me too, I'm personally using Litespeed Cache with the LSCache plugin for Joomla (which is smart to only clear cache of changed objects when they change, instead of all objects)

Just looking out for the betterment of Joomla.

avatar Fedik
Fedik - comment - 1 Apr 2021

Caching single Article can be achieved if the cache stored per article <key> (eg id),
instead of cache/com_content/ could be cache/com_content/<key>/

However this will not help for a list views: blog, category etc. Here need to change the rendering to be per "Item" (instead of per "view"), and then we will be able to cache every item separately.

avatar AndySDH
AndySDH - comment - 7 Sep 2021

Do you guys think this could be improved for Joomla 4?

avatar Fedik
Fedik - comment - 8 Sep 2021

It always can be improved, but I cannot say if it happen in J4.
However the issue is valid, not a high priority but it is valid especially for a large sites that use caching.

avatar Hackwar Hackwar - change - 22 Feb 2023
Labels Added: bug
avatar Hackwar Hackwar - labeled - 22 Feb 2023

Add a Comment

Login with GitHub to post a comment