We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26123
    • 6 Posts
    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
      • 10208 ☆ 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?
        Frogabog- MODX Websites in Portland Oregon
        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
        Having server issues? These guys have MODX Hosting perfected - SkyToaster
        • 26123
        • 6 Posts
        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).
          • 10208 ☆ 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
            Frogabog- MODX Websites in Portland Oregon
            "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
            Having server issues? These guys have MODX Hosting perfected - SkyToaster
            • 38290
            • 712 Posts
            There's also a RegenCache script you can hook up to a CRON job to regenerate cache for all cacheable resources.
            http://devries.jp/blog/2013/03/23/cash-in-big-with-modx-cacheing/
              jpdevries
              • 3749
              • 24,544 Posts
              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.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 36502 ☆ 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...

                  TilliLab | MODX Ambassador
                  website
                  • 28042 ☆ 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?
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 26123
                    • 6 Posts
                    What you say is exactly the point i was expressing!
                    It is a bug or a feature request. smiley

                    I very appreciate the replies this thread got, i hope the dev team can considerate this and do something about this.

                    My preference would be to have a customization form option for duplicate resource.

                    Cheers,
                    Sandro

                    Quote from: sottwell at Jun 25, 2013, 03:15 AM
                    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?
                      • 38290
                      • 712 Posts
                      Does it get cleared even if the resource being duplicated has empty cache unticked?
                        jpdevries