We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41305
    • 4 Posts
    Hi,

    We've just developed a largish Modx 2.2 site (500+ pages) & are in the process of testing. The site exists on a staging server, & then deployed via scripts to a live cluster.

    As I understand it, when you "refresh" the cache, when each individual page on the website is visited for the first time, it is loaded from the database (slower), the second time it is visited it loads from cache (nice & fast).

    The problem we have is that the initial page load after cache refresh are very slow - typically 7-20 seconds PHP time e.g.
    "4 queries, querytime 0.0012 s, phptime 7.4031 s, totaltime 7.4043 s, source database"

    The client has deemed this unexceptable and many burried landing pages will be visited by customers who will take the hit.

    So my question is, how can we make it so after deployment every page in the site is cached & ready to go, without customers having experience the intial delay the first time the page loads?

    Hope that makes sense & thanks in advance,

    Tim.




      • 1343 ☆ A M B ☆
      • 2,213 Posts
      Hello,

      I would take a look at the code on your site first and foremost, any time you edit the site it will clear the cache, so relying on the caching isn't an ideal solution.

      Uncached snippets, conditional logic, and poorly written extras can contribute to the speed issues. If you could share your template we can make some suggestions.
        Patrick | Server Wrangler
        About Me: Website | Tweets |  MODX Hosting
        • 33968
        • 863 Posts
        Yeah, that's way too slow even for uncached pages. Wayfinder is nearly always a major culprit in these cases, try limiting it to one or two levels maximum. And avoid nested getResources calls wherever possible.
          • 3749
          • 24,544 Posts
          This is one solution, although it's very slow and the displayed output can be a little goofy on some platforms. It will completely refresh the cache, however.

          http://bobsguides.com/refreshcache-tutorial.html

          I agree that your site could probably use some optimization.



          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.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
            • 14677
            • 54 Posts
            Creatable Design Reply #5, 14 years ago
            The site is indeed using Wayfinder, I will look into this as the first point of call. It's used in 3 different places in some cases. Most of the snippets used on the site are already set to be cached but there may be a couple of cases where they are not. Thanks for the info.
              • 3749
              • 24,544 Posts
              FYI, Wayfinder should always be cached unless different users will be seeing a different menu.


              [[Wayfinder . . .]]



              ------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using.
              MODX info for everyone: http://bobsguides.com/modx.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
                • 14677
                • 54 Posts
                Creatable Design Reply #7, 14 years ago
                Just checked all the wayfinder calls, and they are indeed cached... I noticed I had placed 2 uncached calls to a MIGx TV (which outputs to a placeholder), so I have now set these to be cached. Just going through each of the templates line by line.
                  • 3749
                  • 24,544 Posts
                  Are you using any PHX-style output modifiers? They can slow things down a lot, especially the conditional modifiers.

                  Complex getResources calls are another common culprit and of course having a lot of images (especially with PhpThumb).


                  ------------------------------------------------------------------------------------------
                  PLEASE, PLEASE specify the version of MODX you are using.
                  MODX info for everyone: http://bobsguides.com/modx.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
                    • 14677
                    • 54 Posts
                    Creatable Design Reply #9, 14 years ago
                    Hi Bob,

                    In some cases I set this up with output modifiers, however I have started switching these to use the IF snippet which has improved the load times somewhat.

                    We have a fair amount of phpthumbof calls some of which use the output modifier too (seemed slower using the snippet form). We have got this down to around 5 seconds on most pages now, some pages still having problems.

                    Thanks for the info.
                      • 36624
                      • 535 Posts
                      I have pretty much the same problem than the original poster.

                      I have made all my possible to cache all i can, i write some custom snippet to avoid multiple getResources, and i use this caching plugin https://gist.github.com/3639503.. but sometimes i NEED to refresh the cache to update the info in multiple parts.. and when this happen ... i'm swear...

                      because :
                      1) it's a important project so when i have some report from the client that the site is slow.. (only the first time yes when the cache is rebuilding..) i feel embarassed to explain why..

                      2) it's a > 600 pages i cant surf all the page myself...

                      So actually the only solution i found ( dont laugh plz ).. I open a webcrawler app on my desktop.. like http://sitesucker.us/ and i crawl the site ... but well.. i cannot tell you how many time i have suck my site with this method.. too many.. :/.

                      Question for the pro :

                      - Do you think in this case i should buy a hosted server to use advanced caching mecanism... actually i'm on shared server like "normal" people.. ?

                      - Do you think we can build a snippet (even better : a CMP) to generate the cache with the API (like "build the site" smiley ( will it be faster and more precise than external app ? )

                      How people with big website in modx do ? please share your idea...
                        CTRL+SHIFT+U - Clear Cache
                        CTRL+SHIFT+H - Hiding Heft Panel
                        CTRL+SHIFT+N - Fast Create Resource
                        CTRL+ALT+P - Preview Recource (in edit resorce window)
                        CTRL+ALT+S - Save