We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1841
    • 141 Posts
    Quick question for any modx expert out there, are there any performance advantages to using static resources like chunks and templates?

    As these are static files does this mean that in theory the database will have a smaller footprint and not come under such heavy load or does the fact that there is a link to the static resource in the DB negate any speed advantages?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      It would all depend on the server in question - how it's configured and what kind of load it's under. The biggest advantage is in minimizing the cache files. Instead of the whole element in the cache, all you have is the link to the static element file.
        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
        Another advantage is the ability to edit them in your favorite editor and put them under version control.


        ------------------------------------------------------------------------------------------
        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
          • 1841
          • 141 Posts
          Thanks for the feedback guys, it's a fairly complicated design with a moderate amount of traffic on a VPS running Centos 6.2.

          I was thinking from the db access times, if it's only dragging a link out the db rather than code this load would be less?
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Not really, the bottleneck is the search for the requested data, not how much it's returning. Keep in mind that a database is basically just a set of compressed data files, and a database engine just parses the file (table) specified in the SQL query. A good way to get a feel for what's going on is to examine an organized text based storage system, such as XML or JSON, where you can read the storage files themselves (more or less). JSON is a bit closer to the concept of an SQL engine, as it also stores metadata for the data in question.
              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
              • 1841
              • 141 Posts
              Thanks Sottwell, I figured as much. I guess as long as it doesn't slow down the site its a nice idea to have these type of resources static. It all adds to the rich experience that is Modx!

              Thanks again for the input, it is much appreciated. Are there any real dis-advantages to using static resources?
                • 10208 ☆ A M B ☆
                • 1,780 Posts
                I think one disadvantage is not being able to use a rich text editor in TV's once you switch from document to static. Oh, and the size of the entry field for the TV's reduces to postage stamp size as well.

                As such, for sites I would ideally like to store html in a static resource for, if there's any user modifiable rich text TV's it can't be static.
                  Frogabog- MODX Websites in Portland Oregon
                  "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                  Having server issues? These guys have MODX Hosting perfected - SkyToaster
                  • 9207 ☆ A M B ☆
                  • 2,475 Posts
                  I can think of a couple other points of comparison:

                  1. If you use static elements for chunks and templates etc. it's much easier to search for text via the command line using grep, whereas searching for text in the database requires more work and SQL knowhow

                  2. Your web permissions must be a bit more carefully controlled when you use static elements. It's a real bummer if MODX can't read from or write to the file correctly.

                  3. Locking: if you use static elements and you are editing them via FTP, it's quite possible some other user will edit the file and you will compete for changes. If it's in the database, MODX should lock the record (although I noticed a bug with this: http://tracker.modx.com/issues/8185)
                    • 1841
                    • 141 Posts
                    Thanks for the feedback everyone, it's also great if you want to store the files outside of the standard file structure too, sharing the static resources with another site without having to share the actual db is a great feature.
                      • 10208 ☆ A M B ☆
                      • 1,780 Posts
                      I feel sorry for the old includeFile snippet. It did such good work for so long and now no one loves it anymore. Being able to edit outside of the manager without setting up includeFile is a most wonderful thing though.

                      RIP Sweet includeFile snippet... oops I mean, Live Long and Prosper in Evo...

                      :~}

                        Frogabog- MODX Websites in Portland Oregon
                        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                        Having server issues? These guys have MODX Hosting perfected - SkyToaster