We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15162
    • 59 Posts
    So I am baffled right now and I don’t know what to say. I run a blog stylish site that publishes news among other things, so the cahce gets cleared relatively often. After cache has cleared I suffer from sluggish load times (<!-- MySQL: 0.0000 s, 0 request(s), PHP: 5.1557 s, total: 5.1557 s, document retrieved from database. -->). With cache everything loads pretty well (<!-- MySQL: 0.0000 s s, 0 request(s), PHP: 1.0168 s s, total: 1.0168 s s, document retrieved from cache. -->).

    But as the cache gets cleared often, I’ve really tried to find ways to bring down the load times without it. Searching for information I came across solutions where people had changed up their site structure completely by giving up as many chunks as possible and removing chunks inside chunks.

    Are chunks mainly for "tpl" purposes? I can’t understand. Isn’t the idea that you can have a sidebar chunk, so you can easily edit your sidebar from one place, when the same sidebar is used in more than one template?

    Example (is this a bad way to execute?):
    I have my sidebar chunk, which is in a template. In the chunk I have three other chunks. In these three other chunks I have a getResources calls.

    Would it be worth it to give up the chunks and just code the code separately inside each template? Or is the catch that I shouldn’t have chunks inside chunks?

    Modx Revo 2.0.8 (traditional)
    MySQL 5.0.91
    PHP 5.2.14
      • 33968
      • 863 Posts
      Hi! Simply having ’chunks inside chunks’ is not likely to have much of an impact on loading time. If it did I think it would be negligible.

      Unless those 3 getResources calls will be used in a different template, you could remove the chunks and place the snippets either into your sidebar chunk or directly into the template just to simplify your setup.

      On the other hand, if you have snippets nested inside snippets then that will cause things to slow down.

      1 second is still too slow coming from the cache in my opinion. There’s a possibility it’s due to a known caching issue that will be addressed in Revo 2.1. But double check your page and all snippets (including Wayfinder if you use it) are set to cached...
        • 15162
        • 59 Posts
        I do have one tpl that has a snippet call in it and I am sure it’s causing some problems. I wouldn’t also put these completely past my host, but in the mean time I’m trying to the best that I can with what I got. I’m aware for the cache fix for 2.1 and it’s bound to help me a lot, but the load times without cache are still going to be over 4s and I’d like to work that down. I have a few snippets called uncached, but they are ones that don’t work if they are not.

        These are pretty normal results for me anyway. The manager speeds are fine for me so I’m not experiencing the same kind of problems that other people have. The site is slowed down by PHP, but as I said, I wouldn’t put it past the host.

        Good to know that chunks aren’t my problem. I might re-check that I don’t have any snippets inside other snippets.
          • 33976 ☆ A M B ☆
          • 571 Posts
          Well, there could be lots of things that might slow your caching. If you want to track the culpable(s), you might want to check Executioner snippet, which will log the processing time of your chunks/snippets calls

          You might also want to consider using getCache (sorry, no link for now since modx.com is down due to maintenance)

          I hope you’ll find a solution (and do not hesitate to keep us informed ^^)
          Good luck
            • 18373 ☆ A M B ☆
            • 3,141 Posts
            getResources and Wayfinder are quite resource-intensive from what I’ve seen, and it’s best not too use them too often. And definitely cached. smiley

            What snippets do you have uncached? If PHP is the culprit it’s probably down to that.

            Another thing that can influence loading times are output modifiers.
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 15162
              • 59 Posts
              Are there any alternatives I can use instead of getResources? I guess replacing Wayfinder wouldn’t be that tough of a job...

              I have a few if snippets called uncached, all else is cached with the exception of getPage. And, well, I use a lot of output filters such as ellipsis, notempty, userinfo and what have you. They are pretty necessary to use, I think. I have all of these snippets in my front page: getResources, getPage, getFeed, phpthumbof, wayfinder and simplesearch. I guess that’s pretty much? I could maybe get rid of Wayfinder and getFeed, but the rest of them I’m not sure.

              And yeah, the snippets are doing it for me. I have pages that don’t use any snippets and they are so much faster than any pages that do.

              modSnippet: Wayfinder executed in 0.0457 s
              modSnippet: SimpleSearchForm executed in 0.0073 s
              modSnippet: getPage executed in 0.5331 s
              modSnippet: getResources executed in 0.7273 s
              modSnippet: getResources executed in 0.4925 s


              So far I’ve managed to sharp some time of by making the calls call less, and by removing unnecessary parameters, but the differences aren’t huge.