We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37165
    • 89 Posts
    I have a site that is moving very very slow. http://buysellrentchicago.com/buildings.html This is especially true on pages where there are a lot of database calls. My hosting company told me that my pages aren't being cached and that's the problem. But I was under the assumption that MOdx caches all resources that have the "cacheable" box checked under settings. Is that not right?

    I read modx documentation on cacheing but it was way over my head. As I started to look around I became even more confused. What are best practices when setting cache options in MODX? Is there a really great package I should be using? I really need to speed this site up and would greatly appreciate being pointed in the right direction.
      • 33337
      • 3,975 Posts
      The "cacheable" box tells MODX that you want this resource cached, and it does exactly that. But in your case, I think the snippet calls are uncached, which could be by ignorance that the developer of the site did not turn on caching of the snippets upon making site live or by necessity where the snippet has to be uncached to function properly.

      I would start looking at the template for that page and see how many snippet calls are there and if they are cached or not. For example:

      Cached snippet call will look like this: [[snippetname? &parameter1=`value`]]
      Uncached snippet call will look like this: [[!snippetname? &parameter1=`value`]]

      Notice the exclamation sign, [[snippet... vs [[!snippet... ? The exclamation sign is telling MODX to run the code "uncached".

      Ideally the snippets should be cached, but most of the pages on the website built by looking at various data points which change with user's interaction. So there are instances where it is necessary to run the code uncached because it needs to load the stuff dynamically in each request. A quick example would be paginated list of news items, you know the page1, page2, page3 etc.

      This will go deep very quickly though, if you have developer at hand with you, you can call him/her and let them have a look or you can hire one of the MODX professionals.

      I hope this helps.
        Zaigham R - MODX Professional | Skype | Email | Twitter

        Digging the interwebs for #MODX gems and bringing it to you. modx.link
        • 3749
        • 24,544 Posts
        There are so many things that can slow down a MODX site that it's difficult to list them all. Probably the most likely (besides uncached snippet calls -- BTW, any Wayfinder calls should be uncached [no exclamation point] unless the menus are customized for the individual user).

        - lots of images, especially large ones
        - getResources calls with TV filters or other complex conditions
        - conditional output modifiers (tags that contain colons (:)

        It might help if you post the Template and the Resource Content field for a particularly slow page.

          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
          • 37165
          • 89 Posts
          Thanks for the explanation zi. That makes sense. There are not many snippets in the templates and the ones that are there are cached. So is way finder. There are a lot of getResources calls with TV filters like BobRay brought up.
            • 33337
            • 3,975 Posts
            If you can put timing tags in the template and then look at the times taken by page, it could help with some efforts.
            <!--
            Query Time: [^qt^]
            Requests: [^q^]
            PHP Exec: [^p^]
            Total time: [^t^]
            Source: [^s^]
            -->
            


            After that I would suggest trying the new snippet from MODX Russian community which is looking better and faster than getResources, it is pdoTools. You can download it via Package Manager inside MODX manager. http://modx.com/extras/package/pdotools

            This package has a snippet named pdoResources, and it is a replacement for getResources. In most cases you can simply replace
            [[getResources? &p=`1` ...]]
            with
            [[pdoResources? &p=`1` ...]]
            and it will just work. I think its worth a try and see if there is significant change in the load times.
              Zaigham R - MODX Professional | Skype | Email | Twitter

              Digging the interwebs for #MODX gems and bringing it to you. modx.link
              • 3749
              • 24,544 Posts
              + on on Zi's suggestion of PdoTools.

              If you really want speed, the best thing is to extend the modUser object. That allows you to put all the fields you now have in TVs into a custom database table.

              Then, rather than getResources, you use a bit of custom code that pulls all the resources in a single query rather than the many queries getResources has to make for each collection. PdoTools is much faster, but it still needs to make multiple queries because of the way TVs are stored.

              Here is one tool for doing that: http://bobsguides.com/classextender-class.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
                • 40045
                • 534 Posts
                you could also wrap the different snippet calls into Executioner from here: https://github.com/opengeek/executioner (usage: https://github.com/opengeek/executioner/tree/v1.0.0-beta/core/components/executioner/docs) and see which snippet calls are the main cause of the slowness...
                  • 37165
                  • 89 Posts
                  Thanks, PdoTools is much faster, but the site is still dragging. I will use this instead of getResources in the future.Quote from: zaigham at May 27, 2014, 09:42 AM
                  If you can put timing tags in the template and then look at the times taken by page, it could help with some efforts.
                  <!--
                  Query Time: [^qt^]
                  Requests: [^q^]
                  PHP Exec: [^p^]
                  Total time: [^t^]
                  Source: [^s^]
                  -->
                  


                  After that I would suggest trying the new snippet from MODX Russian community which is looking better and faster than getResources, it is pdoTools. You can download it via Package Manager inside MODX manager. http://modx.com/extras/package/pdotools

                  This package has a snippet named pdoResources, and it is a replacement for getResources. In most cases you can simply replace
                  [[getResources? &p=`1` ...]]
                  with
                  [[pdoResources? &p=`1` ...]]
                  and it will just work. I think its worth a try and see if there is significant change in the load times.
                    • 37165
                    • 89 Posts
                    This seems very cool, but is a little over my head. I already have many TV fields that are used in various places throughout my site. These fields already have data. It seems like implementing this will loose that info because everything is moved to another database. Will it change the way the site operates on the front end templates, or in the modx manager? Sorry if this is a stupid question. Quote from: BobRay at May 27, 2014, 06:56 PM
                    + on on Zi's suggestion of PdoTools.

                    If you really want speed, the best thing is to extend the modUser object. That allows you to put all the fields you now have in TVs into a custom database table.

                    Then, rather than getResources, you use a bit of custom code that pulls all the resources in a single query rather than the many queries getResources has to make for each collection. PdoTools is much faster, but it still needs to make multiple queries because of the way TVs are stored.

                    Here is one tool for doing that: http://bobsguides.com/classextender-class.html
                      • 20413
                      • 2,877 Posts
                      Tip #1: Avoid or disable phpThumb Cache Manager. http://modx.com/blog/2014/05/29/seven-ways-to-make-modx-fly/
                        @hawproductions | http://mrhaw.com/

                        Infograph: MODX Advanced Install in 7 steps:
                        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower