We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Hi!
    I have a website with about 4.000 resources, several TVs and the use of Phpthumb.

    The staff works in the manager very often and of course they save often...BUT everytime they save cache is cleaned, is it right?

    Can I avoid "clearing cache" after a resource save?
    The parameter cache_resource means that the "content" of a resource is cached?

    If I use the snippet getCache, will I avoid the cache cleaning of elements wrapped by getCache?

    Sorry for so many questions smiley
      TilliLab | MODX Ambassador
      website
      • 3749
      • 24,544 Posts
      You might look at the CacheMaster plugin: http://bobsguides.com/cachemaster-tutorial.html
        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
      • Thanks Bob! I'm going to try it!

        Just few questions:

        - does the plugin work also when I update a chunk or a snippet, with the "clear cache" checked?
        - a snippet called uncached should work fine, isn't it? let's say for example: if I call wayfinder uncached, will it get updated titles even without clearing the cache?

        I read you have not tested it with other cache system, so I won't ask you if you think it would work with xFPC smiley

          TilliLab | MODX Ambassador
          website
        • Calling Wayfinder uncached will definitely put an extra load on your site. In fact, the listing snippets like Wayfinder and getResources are the primary reason why the cache is normally cleared on every resource save. Unless you are creating/editing resources frequently, it's much better to clear the whole cache, and the first person to request a page get the regeneration of the whole page than to have everybody hit with the full generation of the menu or the getResources listing on every page.

          It's a trade-off, you have to consider your site usage and how big your menus and other listings are.
            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
            • 3749
            • 24,544 Posts
            There are good reasons for clearing the whole cache, but if you understand them, there's no reason to have it cleared when you're just updating the text content of a Resource.

            To answer your question, CacheMaster doesn't currently affect elements, only resources, but a future version might.
              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
            • Thanks for your answers, you are absolutely right Wayfinder, at least with my website with many resources, is very slow...

              I was thinking about this workaround:

              1. I call in my templates a chunk cached: [[$menu]]
              2. inside the chunk I call Wayfinder cached [[Wayfinder?...]]
              3. to update the menu I could prepare a page with a snippet or a plugin call that clear only the chunk [[$menu]]

              In this way I should have the menu updated without clearing all the cache, do you think it could work?...

                TilliLab | MODX Ambassador
                website
                • 3749
                • 24,544 Posts
                I'm not sure, but I think that would work. You would only need to do that for new docs (unless you are changing the Menu Title or alias) so you could use a plugin attached to OnDocFormSave with this code at the top:

                if ($modx === modSystemEvent::MODE_UPD) {
                    return;
                }


                If you want to be a little fancier, you could also add code to check for changes in menuindex or alias and *not* return if there are changes.
                  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
                • ok, thanks!
                  Your plugin works fine!

                  I also used this solution to cache Wayfinder better:

                  http://forums.modx.com/thread/39979/wayfinder-slowness-issue?page=3#dis-post-413494

                  (changing the event to oncacheupdate)

                  Now the site is again fast enough.. smiley

                    TilliLab | MODX Ambassador
                    website