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?
ok think about this. An article can be cached as
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.
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:
That's it
Joomla doesn't cache per article or per category. It caches views.
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.
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');
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.
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.
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.
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.
Do you guys think this could be improved for Joomla 4?
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.
Labels |
Added:
bug
|
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
joomla-cms/libraries/src/MVC/Controller/BaseController.php
Lines 660 to 664 in 4172b68
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.