hello,
i've found out that when i right-click on a resource and select the 'duplicate resource', modx clear the website cache. Why?
how can i stop this behaviour?
Thanks,
Sandro
-
☆ A M B ☆
- 1,780 Posts
Because when MODX saves a resource (duplicating=save), the cache is cleared. Otherwise, your new resource wouldn't even show up in the front. Is there a reason you don't want the cache cleared while duplicating?
I've 'disabled' the 'clear cache' option on create/update resource via the custom forms, but the clear cache behavior still persists.
In fact i'd expect that on duplicate resource, modx should cope with create/update custom forms rules, but it's not! is it correct or wrong?
In my case, we have a large website (600+ resources) with daily updates and the site heavily rely on the cache persistence (in fact i'm using a customized plugin to only delete cache of a branch of the tree) so we don't clear the whole website cache (in this way we have everything cached and updated).
-
☆ A M B ☆
- 1,780 Posts
You may want to check into some of the caching Extras available now. CacheMaster might prove to be useful for you, as well as RefreshCache if you do want to re-cache the whole site after a clear.
http://modx.com/extras/package/cachemaster
http://modx.com/extras/package/refreshcache
Look at some of the other caching strategies/extras available as well, something else may be helpful for you in this situation.
http://modx.com/extras/browse/?search=cache
I haven't had time to investigate, but I think RefreshCache is not working in Revolution 2.2.8.
I'd recommend using OpenGeek's RegenCache anyway. I think it will be faster and he knows infinitely more about the cache than I do.
-
☆ A M B ☆
- 491 Posts
Cachemaster works very well for me, but I think it works for update, not for new resources (I'm right Bob?).
And when you duplicate a resource actually you create a new one.
I have the same problem and it would be fine to avoid cache clearing also with this event...
-
☆ A M B ☆
- 24,524 Posts
OnResourceDuplicate is only invoked after the resource has been duplicated, and there's not option to clear the empty cache field. In modresource.class.php in the duplicate() function there is an array for overrides
/* allow overrides for every item */
if (!empty($options['overrides']) && is_array($options['overrides'])) {
$newResource->fromArray($options['overrides']);
}
But I don't know how one would add such an override to the default "on" for syncsite, other than to hack the duplicate() function.
I would say this should be a feature request to add it to the set of options when duplicating a resource. That would be done in the manager/assets/modext/widgets/window.js file, adding a radio button field block around line 58. But using the Tree's context menu behaves differently from using the Duplicate button, so unless and until these different methods of doing the same thing are properly synchronized it'll be a problem. Could it be considered a bug that they don't behave in the same manner?
Does it get cleared even if the resource being duplicated has empty cache unticked?
jpdevries