Seven Ways to Make MODX Fly

Having a fast website today is critical, but what happens when you begin to suffer from your own success? Here are a few ways you can make MODX sites fly, resulting in better conversion, SEO, and visitor engagement.

By Ryan Thrash  |  Updated: September 11, 2023  |  6 min read
Seven Ways to Make MODX Fly

Having a fast website today is critical, but what happens when you begin to suffer from your own success? Here are a few ways you can make MODX sites fly, resulting in better conversion, SEO, and visitor engagement.

The Importance of Performance on the Web

Winning online requires a fast website.

Google sets the standards. Both Google and actual oxygen-breathing people love sites that let them quickly and seamlessly find what they’re looking for.

Fortunately, MODX is one of the fastest Open Source CMSes because speed was one of its core design principles from day one. It also gives web developers complete control over HTML markup, site structure, and user experience without having to resort to hacking the core, compromising with site builders that output bloated markup, adding yet another plugin (YAP), or relegating caching to an afterthought.

The tips below summarize what we’ve learned from over a decade of helping people get the most out of MODX. While there are many more things you can do to optimize performance, the following areas will usually make a more-than-noticeable improvement for any site that needs help.

Know Your Starting Point

To start, you should objectively understand how your site performs.

A great tool for this is GTMetrix. In just a few minutes, you can know how your site currently performs on Core Web Vitals (CWV). CWV is a set of measurements that Google uses in its search ranking algorithm to determine how your site’s user experience for visitors stacks up.

And as Google goes, so do most other search engines. If you do well there, you should do well elsewhere.

In short, you ideally want to be solidly in the green on all CWV scores for all your most frequently visited or important web pages.

CDN to the Rescue

A content delivery network (CDN) is the fastest way to speed up your website. You’ll often see this as one of the key recommendations in the GTMetrix reports mentioned above.

A CDN makes serving your images, videos, CSS, JS, audio files, and other site assets much faster by serving them close to your customers using servers purpose-built to spit out files fast. Some CDNs will also cache your HTML and serve that for you, too.

Adding a CDN to your website in MODX Cloud is just a button click away, including optimal configurations, awesome support, and a plugin that clears the CDN cache when you update your pages.

Tip #1: Use a Content Delivery Network.

Dealing with Image & Thumbnails

Large web pages—often resulting from from unoptimized images—can degrade your visitors’ experience. Especially if they’re on a less-than-ideal mobile connection.

But optimizing images is neither fun nor something most site owners truly understand how to do well.

Many web developers turn to the free Open Source software phpThumb to help with resizing images correctly. In fact, MODX includes it with every download as part of its core distribution.

But unfortunately, while it’s a very robust piece of code, it isn’t the most optimal when it comes to resizing images for busy sites. In fact, phpThumb can crush even the largest of servers out there, especially when its evil sidekick, the Cache Manager Plug-in, is left on in production.

Tip #2: Disable phpThumb Cache Manager. While the Cache Manager Plug-in can be useful, it’s also easy to fall into unintended misuse/abuse, leading to the destruction of any chance of your site performing well. Avoid it unless you really, really, really know what you’re doing and why.

Tip #3: Use pThumb to generate thumbnails. This is a more performant alternative to generating thumbnails with scaling in mind. It’s a drop in replacement for phpThumbOf so all you have to do is swap them out.

ABC: Always Be Caching

Caching is probably the most important thing you can do for any MODX project. It also gets into the geekier underpinnings of how the web works. Jason Coward wrote an excellent in depth article on caching. YJ Tso expanded on that one with more discussion and examples. Both should be required studies for any serious MODX site builder.

Caching also extends to the PHP server layer, via "opcode caching". In our experience, at the time of publishing this article we usually get better performance and reliability using APC compared to Xcache. But, that is likely to change over time. No matter where you are today, it's likely there will be something faster tomorrow, so it can pay to keep things up to date and evaluate options.

Tip #4: Always Be Caching (ABC). Always. Every time. Seriously. If you don’t have the expertise to know if you’re doing it right, get some help from someone that does.

Tip #5: Use an OpCode Cache. PHP 8+ have OPcache built in; prior versions usually perform best with APC.

Use the latest PHP & NGINX

At the time of this article update, MODX Cloud uses the latest stable branch of NGINX and PHP—and constantly improves configurations to serve your sites as fast as possible. This software stack takes advantage of modern browser capabilities and automatic optimization to help sites render more quickly, keeping site visitors happier and around longer.

Tip #6: Newer versions of NGINX and PHP versions can improve site performance substantially. Many commodity web hosts don’t keep up with updates and use Apache, which just can’t match the speed of a tuned NGINX/PHP-FPM web server stack. PHP 5.x and 7.x are no longer supported, so upgrade today!

Throw Hardware at It

We’ve helped sites go from slow responseses and timeouts under load even with 96GB of RAM and 32 processor cores, to flying on 4 cores and 8 GB RAM—with no outages. Similarly, we’ve helped build out infrastructure with multiple load-balanced webservers, database clusters and Memcached, Varnish and/or Redis.

Sometimes you just have traffic levels that justify a bigger hardware budget—or the time involved in optimization is more expensive than extra servers. When you can’t squeak more out of your site using techniques like the ones above, you often need to just give it more IO.

Tip #7: Deploy more server resources. A quick technique would be to make more PHP workers available to your site to increase the number of maximum visitors it can sustain. Often this means getting a larger plan, bigger VPS or a dedicated box. And sometimes, it just takes multiple, highly-tuned servers.

Conclusion

There is a lot under the hood that savvy site builders can do to make MODX sites serve visitors blazing-fast. You can also go the extra mile to create function-specific code to replace much-loved, but sometimes suboptimally-performing “generic” Snippets, for sites with larger visitor loads.

Making the most of MODX is a process, not a destination, and best practices change over time. If you ever need help improving MODX site performance, we’re happy to talk.