Hello! We are online right now 13:32:03

The support team is online and will be able to answer your inquiries. Please stay calm, follow the rules and do not cross post. We'll attend to you as soon as we can.

Official support hours are from 8:30AM — 5:00PM Monday to Saturday (GMT +7)

JLex Comment: Cache LifeTime setting

AndySDH
Hello, I believe that at the moment when "Cache mode" is set to 'Yes', JLex used the cache time set in Global Configuration.

However, it would be great if you could override the default setting with a custom cache time.

Is it possible for you to add a Cache Lifetime setting to JLex comment?

Meaning that, IF "Cache mode" is set to 'Yes':
https://i.imgur.com/XFJzuGK.png
A new setting appears called "Cache Time", where you can enter the amount of minutes:

https://i.imgur.com/DEveY7U.png

I believe you can find an example here: https://gist.github.com/esedic/859b2f5b256d590f624cbb8913925257
(see $cache->setLifeTime)
I'm not 100% sure this is how it's done, probably you know better :D

Let me know, thanks!

18 replies

JLexArt
In this week, she will report this issue :D it not too long.

Best regards,
Victor Nguyen.
@AndySDH is wrote at 2021-10-29 07:15:41
In the meanwhile you can send me the beta so i can test the updated cache features and check those :)
JLexArt
@Andy: Thanks for your info but I cannot add Cache time for JLex Comment because it cannot work independently.
Example:
When you integrate JLex Comment for Joomla Content and enable Cache, now all comments is a part of article and it just be refreshed when article cache is cleared.

Best regards,
Victor Nguyen.
JLexArt
@Andy:
1) Yes, the Cache still added to JLex Comment because some case Global Cache is enabled for whole site but client want disable it for JLex Comment only.
You can see com_jlexcomment cache folder but it still depend to com_content folder too ;).

2) I don't test with module, but with inheritance of advanced parameters related to caching, I think it's possible. As I know, the Custom Module of joomla support Cache Time, you can use this module and insert JLex Comment module into it.

Hope can help you!

Best regards,
Victor Nguyen.
COM_TOPIC_COMMENT_QUOTED_REMOVED
JLexArt
@Andy: Thanks for your feedback! I will remove com_jlexcomment cache folder in the future.
About Cache time of module, I will consider add it to next month ;). This month for Youtube module :D.

Best regards,
Victor Nguyen.
COM_TOPIC_COMMENT_QUOTED_REMOVED
AndySDH
Ok, I've done some extensive testing of the cache features, I analyzed the whole cache situation, and I changed my mind ona lot of things.

Like you, initially, I was thinking that the com_jlexcomment cache could be removed. But at the end of my tests, I realized that the com_jlexcomment cache folder is actually useful and should stay.

Here are my conclusions and explanations:

Cache folders for JLex Comment:

mod_jlexcomment folder: When using the JLex Module, especially as "Dynamic Item", if you enable caching of the module, you will have a big problem: the comment form will be the same in all articles (it won't be dynamic item anymore). This is because the module is only cached once for all pages.
This means, that the JLex Module is really not eligible to be cached on its own. So, forget about adding "Cache Time" here :D You should instead remove the "Caching" option completely for the Module under the "Module->Advanced" tab. The module should continue to just rely on the com_jlexcomment folder, and doesn't need its own folder.

-----

com_jlexcomment folder: It's true that when using the JLex Plugin, the com_jlexcomment cache folder should not be necessary, because the content of the comments is usually already cached by the respective component (eg. com_content cache).
So this initially lead me to believe that the com_jlexcomment cache folder could be removed.
However, when using the JLex Module, the com_jlexcomment folder is useful because when using the module, comments are not cached by the respective component.
And as explained earlier, for this we cannot rely on the mod_jlexcomment folder (which can be removed).
The module has to keep relying on the com_jlexcomment folder (like it already is now), which indeed stores a cache for each separate object. So for this reason, the com_jlexcomment folder should remain.

Also, the com_jlexcomment folder can be useful in another scenario: do all these components use Joomla cache? https://www.jlexart.com/addons/jlex-comment+
I don't know. But for the components that don't use Joomla cache, the comments will still be cached via the com_jlexcomment folder.

-----------------

Cache Time Setting for JLex Comment:

Now, regarding the "Cache Time". Adding a Cache Time to the module is now out of the question because it doesn't make sense to cache the module individually. So it should not be in the module. As mentioned, the whole "Caching" option should be removed from the module.

So, where to add "Cache Time"? Cache Time should be added in "JLex Comment->Settings->Advanced", under  the "Cache Mode" setting.

It's true that like you said, the Cache Time will not apply when using the plugin because the plugin is already cached inside the cache of the respective component (eg. com_content)

However, the Cache Time will apply in these two scenarios:
- will apply for comment objects inserted via the JLex module (which have independent caching from component)
- will apply for plugins of components that don't use use cache.

So you could add the Cache Time setting with this tooltip/description:

"Note: This Cache Time setting will not work when using a component that is already controlled by Joomla Cache Time (eg. com_content). However, it will work when using components that don't use Joomla Cache, and it will work when using the JLex Comment module"

-----------------

Renaming of the "Cache Mode" description:

Under the "JLex Comment->Settings->Advanced" area, I think the "Cache mode" description/tooltip should be renamed to make it more clear on how it works:

"When set to Yes, if the Joomla Cache is enabled, the comments form will be cached, and new comments will appear when the cache expires or is cleared. When set to Disable, the comments form will use an Ajax dynamic system that will make new comments always update in real-time."

-----------

I hope this analysis is useful :)
@JLexArt is wrote at 2021-10-01 08:43:35
@Andy: Thanks for your feedback! I will remove com_jlexcomment cache folder in the future. About Cache time of module, I will consider add it to next month ;). This month for Youtube module :D. Best regards, Victor Nguyen.
JLexArt
Thanks for your analysis. Just like you said, the cache of module will not work in dynamic parameters. I will consider to bring this feature back ;).

Best regards,
Victor Nguyen.
@AndySDH is wrote at 2021-10-02 08:54:47
Ok, I've done some extensive testing of the cache features, I analyzed the whole cache situation, and I changed my mind ona lot of things. Like you, initially, I was thinking that the com_jlexcomment cache could be removed. But [b]at the end of my tests, I realized that the com_jlexcomment cache folder is actually useful and should stay.[/b] Here are my conclusions and explanations: [b][u]Cache folders for JLex Comment:[/u][/b] [b]mod_jlexcomment folder: [/b]When using the JLex Module, especially as "Dynamic Item", if you enable caching of the module, you will have a big problem: the comment form will be the same in all articles (it won't be dynamic item anymore). This is because the module is only cached once for all pages. This means, that the JLex Module is really not eligible to be cached on its own. So, forget about adding "Cache Time" here :D[b] You should instead remove the "Caching" option completely for the Module[/b] under the "Module->Advanced" tab. The module should continue to just rely on the com_jlexcomment folder, and doesn't need its own folder. ----- [b]com_jlexcomment folder:[/b] It's true that when using the JLex Plugin, the com_jlexcomment cache folder should not be necessary, because the content of the comments is usually already cached by the respective component (eg. com_content cache). So this initially lead me to believe that the com_jlexcomment cache folder could be removed. However, when using the JLex Module, [b]the com_jlexcomment folder is useful because when using the module[/b], comments are not cached by the respective component. And as explained earlier, for this we cannot rely on the mod_jlexcomment folder (which can be removed). The module has to keep relying on the com_jlexcomment folder (like it already is now), which indeed stores a cache for each separate object. [b]So for this reason, the com_jlexcomment folder should remain.[/b] Also, the com_jlexcomment folder can be useful in another scenario: do all these components use Joomla cache? https://www.jlexart.com/addons/jlex-comment+ I don't know. But[b] for the components that don't use Joomla cache[/b], the comments will still be cached via the com_jlexcomment folder. ----------------- [b][u]Cache Time Setting for JLex Comment:[/u][/b] Now, regarding the "Cache Time". Adding a Cache Time to the module is now out of the question because it doesn't make sense to cache the module individually. So it should not be in the module. As mentioned, the whole "Caching" option should be removed from the module. So, where to add "Cache Time"? Cache Time should be added in "JLex Comment->Settings->Advanced", under  the "Cache Mode" setting. It's true that like you said, the Cache Time will not apply when using the plugin because the plugin is already cached inside the cache of the respective component (eg. com_content) [b]However, the Cache Time will apply in these two scenarios:[/b] - will apply for comment objects inserted via the JLex module (which have independent caching from component) - will apply for plugins of components that don't use use cache. So you could add the [b]Cache Time setting[/b] with this tooltip/description: [i]"Note: This Cache Time setting will not work when using a component that is already controlled by Joomla Cache Time (eg. com_content). However, it will work when using components that don't use Joomla Cache, and it will work when using the JLex Comment module"[/i] ----------------- [b][u]Renaming of the "Cache Mode" description:[/u][/b] Under the "JLex Comment->Settings->Advanced" area, I think the "Cache mode" description/tooltip should be renamed to make it more clear on how it works: [i]"When set to Yes, if the Joomla Cache is enabled, the comments form will be cached, and new comments will appear when the cache expires or is cleared. When set to Disable, the comments form will use an Ajax dynamic system that will make new comments always update in real-time."[/i] ----------- I hope this analysis is useful :)
JLexArt
@Andy: I added Caching time & improve cache featured as your suggestion ;).

Best regards,
Victor Nguyen.
COM_TOPIC_COMMENT_QUOTED_REMOVED
AndySDH
Hello,
I just renewed my license...

I looked at the updated code. I see that you implemented cache time, which is nice.

However, your updates to clearCache() are wrong. You now made it that if cache is enabled, every time a comment is posted, the cache of the whole site is cleared (all folders). Why?? I never suggested something like this so I'm not sure where you got this idea from :ermm:

The clearCache() function is not needed, it was good like it was before that you had it // commented out. There is no need for it.

If people want cache off, they can put it to "Disabled", where the comment form uses ajax and thus has no cache.

Oh, and you also forgot language strings....

Sorry but you made a sloppy update....
@JLexArt is wrote at 2021-10-20 08:22:41
@Andy: I added Caching time & improve cache featured as your suggestion ;). Best regards, Victor Nguyen.
JLexArt
@Andy: I have added Caching Time as your suggestion. Regarding the clearCache() function, I would edit it that instead of clearing the entire site cache, it will only clear the com_jlexcomment folder. It would be better than doing nothing when there is a comment with added.
Of course you can remove these lines of code to keep the cache.

Regarding the language file, I hope you will send me the complete file or mark the lines that you fix, it will help me more.


Best regards,
Victor Nguyen.
@AndySDH is wrote at 2021-10-20 15:07:07
Hello, I just renewed my license... I looked at the updated code. I see that you implemented cache time, which is nice. However, your updates to clearCache() are wrong. You now made it that if cache is enabled, every time a comment is posted, the cache of the whole site is cleared (all folders). Why?? I never suggested something like this so I'm not sure where you got this idea from :ermm: The clearCache() function is not needed, it was good like it was before that you had it // commented out. There is no need for it. If people want cache off, they can put it to "Disabled", where the comment form uses ajax and thus has no cache. Oh, and you also forgot language strings.... Sorry but you made a sloppy update....
AndySDH

Regarding the clearCache() function, I would edit it that instead of clearing the entire site cache, it will only clear the com_jlexcomment folder.




That would definitely be better, yes :)

----------

But: even like this, if the com_jlexcomment cache is cleared when a comment is posted, then Caching Time will pretty much never be used. For example, say you put Cache Time to 3 hours. But you have a comment every 10 minutes. Cache Time will never be used... cache will always expire every 10 minutes.

Maybe a good solution would be to have 3 options for "Cache Mode":
0: Disable (same as now)

1: Cache by time: This will use the "Cache Time" setting. The com_jlexcomment cache will only expire when the cache time limit is reached.

2: Clear on change: This will clear the com_jlexcomment folder cache when adding a new comment, changing state / featured, or deleting a comment.

So essentially, the clearCache() function should only be triggered if:
$config->get("cache") == 2

What do you think?


Regarding the language file, I hope you will send me the complete file or mark the lines that you fix, it will help me more.




I meant to say that you forgot to implement a language string for: "JCM_COMMENT_CACHE_TIME".

But yes, now that you remind me, we still have to do the update for the whole language files, I will update with a reply in the other forum thread.
@JLexArt is wrote at 2021-10-21 08:22:18
@Andy: I have added Caching Time as your suggestion. Regarding the clearCache() function, I would edit it that instead of clearing the entire site cache, it will only clear the [b]com_jlexcomment[/b] folder. It would be better than doing nothing when there is a comment with added. Of course you can remove these lines of code to keep the cache. Regarding the language file, I hope you will send me the complete file or [b]mark the lines that you fix[/b], it will help me more. Best regards, Victor Nguyen.
Reply to

Sign in to your account

Use your social accounts to sign in