Saving clientConfig Options do not update in Templates and Chunks Confused on How To Handle

Hi! New to MODX dev here so could be missing something simple, but I am using ClientConfig to setup some items that do not change often such as client phone numbers but from time to time they will change and right now if i go and update the client options it does not update on the site, the Chunks and Templates will only grab the new info if i go to the Template and Resave it -or- resave the page. Is there a way to Resave all the chunks and templates each time the config is saved? Or is there a better way to have those options update inside the chunks and templates when we update them?

It’s likely your settings are just getting cached.

You could try calling your settings uncached - so instaed of:

[[++your-setting]]

try:

[[!++your-setting]]

1 Like

Thanks so much! I figured I was missing something simple, that did the trick.

1 Like

Glad you’re sorted - welcome to MODX!

PS - many MODX tags can be called cached or uncached.

@markh has a good video on the subject if you’d like to learn more.

If those settings don’t change often, you could just manually clear the cache on the occasions when they are updated. Leaving the tags cached would provide a performance boost, although I’m not sure how noticeable it would be.

1 Like

Looking again - ClientConfig actually has a system setting: clientconfig.clear_cache

This is enabled by default and it looks to me like it should clear the cache when you save your ClientConfig settings.

However - in my experience, the cache usually needs to be cleared manually after saving, or the placeholder needs to be called uncached.

Perhaps @markh can clarify …

Those settings do not change often, so I would rather them be cached. I currently have a plugin I made that is dynamically generating a css style sheet everytime the options are saved, ideally I’d like to have that php script also clear the cache each time the option is saved. I was looking through the documentation to see if there was something I can include in there to initiate the cache to clear didn’t see anything yet, I was still looking around the docs. Do you know of anyway of forcing a cache clear through a php script? If so that would give me exactly what I’m looking for.

Yeah I haven’t changed the default setting and I get the same results your seeing,

Try the following in your php to clear the full cache:

$modx->cacheManager->refresh();

More detail here.

The CacheClear extra will do the equivalent of clearing the cache manually. I use it often when the Manager’s cache clear doesn’t do the job completely.

Another nice thing to have during development is the Classic Cache Killer extension for Chrome. With one click, you can turn the Chrome browser cache off completely. Sometimes it’s difficult to tell if it’s the MODX cache or the browser cache that’s keeping changes from showing up.

1 Like

Thanks so much this is exactly what i was looking for, working perfect now, Thanks for everyones help!

1 Like

Be aware that this call refreshes the entire cache and slows down page loads. It’s fine during development, but you might not want it permanently.

1 Like

Sounds like a bug - the cache clear is supposed to wipe the resource cache so any cached tags will get reprocessed automatically.

If you could report an issue in the tracker that’d be much appreciated so we can look at why that’s not behaving as intended.

2 Likes

Done! - issue raised …

2 Likes