We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16942
    • 33 Posts
    I have two sites running modx. Both of which have simple templates mainly using getResources and Wayfinder.

    I’ve noticed, the first time you hit a page after clearing the modx site cache it can take up to 8 seconds to render the page. This is terribly slow.

    What are the usual reasons for such slow performance - or, is this in fact quite normal?

    I need to find a way of bringing that page generation time right down to about 2 or 3 seconds. Pages which are current in the modx site cache take about 3 seconds which is, although not ideal, within acceptable tolerances.

    I’m happy to provide any information to help get to the bottom of this...and perhaps we can share some learnings for those who follow us.
      • 33968
      • 863 Posts
      Hi Leo

      How many resources are you listing in both the Wayfinder and getResources snippet calls?
      Both can get a bit slow if forced to loop through a lot of items, especially if TV values are required.

      Have a look at wrapping your snippet calls with the Executioner snippet which will give you an idea of how long each take to execute.
        • 22303 MODX Staff
        • 10,725 Posts
        FWIW:

        In 2.0, when you clear the cache, the context cache has to be generated by querying every resource and all of it’s parents to build the virtual URI it responds to in MODX. The long page generation after clearing the cache is due to this.

        In 2.1, when you "refresh" the cache, the context caches are all recreated (never deleted) from a single query using the new uri field. This helps immensely if you clear the cache often during peak traffic times. There are numerous other speed improvements in MODX Revolution 2.1.x as well that should help with whatever is causing your slow performance issues.
          • 16942
          • 33 Posts
          I’ve got one site running 2.1.1 which has 5 nav items surfaced through wayfinder on its homepage.

          And then the 2.0.8 site - I’ve just checked and in fact its nav is just hardcoded but the homepage template does have about 3 or 4 custom template variables which just spit out text (but via filters like nl2br and a string shortener)

          So one would think the latter should render very fast.
            • 3749
            • 24,544 Posts
            Output modifiers can slow things down a lot (especially conditional ones) because each output modifier has to be identified, parsed, and then executed separately.

            Replacing them with custom snippets can sometimes make a big difference.
              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
              • 16942
              • 33 Posts
              On the 2.0.8 site homepage we have just one TV rendered through output modifiers as follows:

              [[*HomepageAnnouncement:nl2br:shorten=`170`]]

              (shorten is an excellent snippet if anyone’s used it before)

              I’d be very surprised if the above slowed render times down that much.
                • 28215
                • 4,149 Posts
                HEY YOU, READ THIS! If you’re posting about a bug, please state all of your Environment information in your post: Version of MODx, Traditional or Advanced distribution (for Revo), Server OS, Server Version, PHP Version, MySQL Version (client and server), is pdo_mysql installed, your Browser type and version, if you are using any opcode caching such as eAccelerator, APC, winCache, xCache, etc; any relevant errors in core/cache/logs/error.log, and any other environment data we should know. We can’t help you without that information.
                  shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                  • 33968
                  • 863 Posts
                  In your first post you said that both sites were running getResources and Wayfinder. If that’s the case, they are the most obvious causes of performance issues so at least rule them out by running Executioner on each one and noting how long they take to execute.
                    • 16942
                    • 33 Posts
                    Let’s start with the 2.0.8 site

                    ENV INFO:

                    MODx version: Revo 2.0.8-pl (trad)
                    Codename: Revolution
                    ExtJS: 3.3.0
                    Smarty: 3.0.4
                    PHPMailer: 2.0.4
                    MagpieRSS: 0.7a
                    Database type: mysql
                    Database version: 5.1.49
                    Database charset: latin1
                    MySQL Support: enabled
                    Active Persistent Links: 0
                    Active Links: 0
                    Client API version: 5.0.67
                    MYSQL_MODULE_TYPE: external
                    mysql.allow_persistent: Off,Off
                    mysql.connect_timeout: 60,60
                    mysql.max_links: Unlim,Unlim
                    mysql.max_persistent: Unlim, Unlim
                    PDO support: enabled
                    PDO drivers: mysql, pgsql, sqlite, sqlite2
                    PDO Driver for MySQL, client library version 5.0.67

                    Host Info
                    Type: Shared Hosting
                    Stack: Linux, PHP 5.2.14 (Apache CGI), Apache, MySQL 5.0.67

                    Error Log - is empty

                    I’ll try the executioner later on and see if that sheds some light on it. If we can get the 2.0.8 running like a well-oiled machine, we can tackle the more complex 2.1.1 site. Get both of these working and I’m also hoping that we have a useful thread on here for others in the future.
                      • 16942
                      • 33 Posts
                      Now on the 2.0.8 site, we have a product index page which uses Wayfinder to pull in the page titles of 10 items (nothing else other than page title and url) and here’s what Executioner has to say

                      [2011-07-14 14:03:53] (ERROR @ /index.php) modSnippet: Wayfinder executed in 1.2907 s


                      Wow.