One of the big reasons that so many people love WordPress is that you can use it to create pretty much any type of website. From blogs to eCommerce stores to membership sites, WordPress can do it all. But…the same can’t be said for the average WordPress host…
While pretty much any host can handle a simple WordPress blog or brochure site, WordPress sites that rely more heavily on dynamic content, like eCommerce stores or membership sites, require a more detailed approach to hosting and optimization if you want them to perform well.
For example, you’ll hear horror stories of the WooCommerce dashboard that takes minutes to load or run reports. Or the online course content that takes forever to load and frustrates course-takers.
To help you avoid that being your site, we’re going to dig into 9 tips for hosting dynamic WordPress sites like:
- eCommerce stores built with WooCommerce or Easy Digital Downloads;
- Membership sites built with any one of the many quality membership plugins out there;
- Online courses built with LMS plugins;
- Social networking sites based on BuddyPress, PeepSo, or others;
- Forums built with bbPress or BuddyPress.
Three big reasons why dynamic sites require special attention
There are a few things going on with these types of dynamic sites that force you to treat them differently than your average WordPress site.
1. Dynamic sites have more complex database queries
By their nature, dynamic sites are going to generate more database queries, as well as more complex database queries because dynamic sites often have large amounts of data, as well as a heavy reliance on search.
For example, users are much more likely to search on an eCommerce store or a forum than a simple brochure site.
All this adds more strain on your server as it tries to serve up information from your WordPress site’s database.
2. You won’t be able to use page caching everywhere
For many WordPress users, page caching is kind of the holy grail of WordPress performance. But with highly dynamic sites, you’re going to have a great deal of content that simply can’t be cached without breaking key functionality.
For example, trying to cache a forum won’t work because members are always creating new topics and replies. Similarly, you can’t cache the WooCommerce cart and checkout pages without breaking their functionality.
So while you might still be able to cache some pages – like a static homepage or about page – you won’t be able to rely on caching for much of your content.
Many caching setups also exclude logged-in users from being served cached pages. That’s fine when you only have an admin and a few authors…but when you have thousands of active registered users, that means a significant chunk of your traffic is going to bypass the cache no matter what.
If you’re using a third-party plugin or solution that relies on PHP sessions, this can also play havoc when it comes to implementing the caching correctly. Why? Because a unique PHPSESSID is generated on every single request. If this is cached, it could break the functionality of whatever depends on it.
3. Dynamic sites often have lots of concurrent visitors
While a large number of concurrent visitors isn’t unique to dynamic sites, it’s more likely that a dynamic site receives higher traffic simply because dynamic sites are more likely to be heavily promoted.
So when you add a large number of concurrent visitors on top of complex database queries and lots of uncached content, you can start to see why dynamic sites can’t just use your run-of-the-mill shared host.
Nine tips for hosting dynamic sites to make them load quickly (even under scale)
Ok, so now you know that you need to pay special attention to your host if you’re running a dynamic WordPress site…but what does that actually mean?
Now, let’s get into some of the actionable tips to make sure your dynamic site:
- Loads quickly (enough said!)
- Is reliable (no crashes!)
- Can handle high traffic (don’t miss out on going viral because your site crashes!)
1. Go for a performance-optimized hosting
While you can utilize some of the other tips on this list to improve your site’s performance no matter where it’s hosted, the simple fact is that your host is always going to be one of the biggest bottlenecks for performance.
For many reasons, cheap shared hosting just can’t provide the resources necessary to optimize performance for a dynamic site with any significant amount of traffic.
As a result, spending the extra money on a quality performance-optimized host is a necessity. Such a host should give you your own private server resources, as well as many technologies that we’ll feature over the next sections like:
- PHP 7.2;
2. Make sure you’re running PHP 7.2 (or at least PHP 7+)
There is a range of reasons why you should be running the latest version of PHP, starting with the fact that PHP 5.6 and 7.0 will no longer receive security support at the end of 2018.
Beyond that, PHP 7+ (especially PHP 7.2) offers major performance benefits over older versions of PHP. According to Kinsta’s PHP benchmarks, PHP 7.2 more than doubled PHP 5.6’s requests per second when it came to WooCommerce, and it also edged out PHP 7.0 and PHP 7.1, though the difference isn’t quite as large:
And you can see the same disparity on an Easy Digital Downloads test site:
Given that PHP 7.2 offers both massive performance improvements, as well as active security updates, it’s essential to choose a host that lets you run PHP 7.2.
But despite that, there’s still a huge percentage of WordPress sites running on older versions of PHP, with 38% of WordPress sites using PHP 5.6 (that’s, by far, the plurality).
So – find a host that offers the latest version of PHP and, more importantly, make sure you’re actually running the latest version on your server.
3. Use elastic search to speed up search (and reduce performance load)
If your site relies heavily on search, you might run into performance issues as a result. Some examples are sites that:
- Rely heavily on WP_Query;
- Use search as a primary navigation method (again, an eCommerce store is a good example here, as many shoppers will go straight to search to find the products they’re interested in).
Elasticsearch can speed up database queries at your site by building an index of your site’s database. Then, Elasticsearch can search this index, which is faster than relying on a MySQL query:
Ideally, you should look for a host that lets you install Elasticsearch on the same server as your PHP environment and MySQL database, as that decreases the latency versus using the hosted version of Elasticsearch or hosting Elasticsearch in a separate environment.
4. Take advantage of object caching
While simple WordPress sites won’t get a huge benefit from object caching, object caching makes a great option for dynamic sites.
Object caching is different than page caching, which is what most people think of when they hear caching and WordPress. It works by caching the results of database queries, which lets your server serve up identical queries from the cache rather than needing to query the database again.
There are a few different ways that you can implement object caching for your WordPress site. If available, Redis is our recommended option for object caching as it lets you benefit from persistent object caching.
If you don’t have access to Redis at your host, other options include:
- Some WordPress caching plugins, notably W3 Total Cache;
5. Offload static files to external storage (and use CDN)
Dynamic sites often plain just have a lot of data. Think product images, user uploaded photos, course videos, etc.
All that data can eat up storage, which is a big deal as many performance-optimized hosts offer far less storage space than “unlimited” shared hosts. Additionally, those are extra requests that your server has to process.
Rather than storing these types of static files locally, you can offload your media to an object storage service like Amazon S3, DigitalOcean Spaces, or Google Cloud Storage.
Not only does this reduce the requests to your server, but it might also save you some money as these services are typically cheaper than purchasing more storage space from your host.
Additionally, most CDNs still make it easy to serve up images from any one of those services, so you can still harness the benefits of a CDN even if you opt to use external object storage.
To help you offload your files, you can use the popular WP Offload Media plugin from Delicious Brains.
6. Optimize your site’s database on a regular basis
As you’ve learned, dynamic WordPress sites are much more database intensive than your run-of-the-mill WordPress site. But in addition to all the important information that’s housed in your site’s database, your database will also pick up plenty of “junk” along the way in the form of:
- Transients (you can use the Transients Manager plugin to manage them);
- Autoloaded data (learn how to delete autoloaded data here).
Beyond clearing out this information periodically, you can also further optimize your site’s database by moving to InnoDB, if you haven’t already.
7. Increase the number of PHP workers
While this won’t apply to all hosts, many higher-tier hosts limit your plan using something called PHP Workers, whereas shared hosts typically set a limit based on CPU usage or RAM.
PHP Workers control how many requests your site can process at a time. For example, if you have one PHP worker, you can process one request at a time. So if three uncached requests hit your site, the second and third requests will have to wait until the first is finished.
As we talked about earlier, dynamic sites are naturally going to have a higher number of uncached requests, which means that the number of PHP workers on your plan can quickly become the bottleneck for your site’s performance.
The solution is simple – increase the number of PHP workers. If you go from one PHP worker to two PHP workers, your server can now simultaneously process two uncached requests at a time, which boosts performance, especially when your site has large numbers of concurrent visitors.
You’ll need to talk directly to your host about increasing PHP workers on your plan.
8. Avoid unnecessary plugins, especially those that add database queries
While you should avoid all unnecessary plugins, pay special attention to any type of post or view counter plugins. For example, you might be tempted to show how many views each topic has on your forum.
While that’s neat for showing how active your site is, it also adds even more load to your database, which is likely to already be stressed as it is.
So if possible, avoid “counter” functionality. And if you absolutely do need a counter (like social media share counts), then:
- Try to limit where those numbers appear;
- Use a plugin that lets you cache the results (many social share buttons let you control how long to cache share counts for).
This is a good rule of thumb for any WordPress site, but it’s especially important for dynamic sites as your server is likely to be stressed already.
9. Make sure your 404 page doesn’t consume unnecessary resources
You probably don’t think about your 404 page that often, but it can be a silent drag on your site’s performance, especially if your site’s 404 page is resource-heavy. This is especially true as dynamic sites often generate a higher than the average number of 404 errors.
Your host should give you a tool to monitor 404 errors. And you can also use Google Search Console to see 404 errors that Googlebot encounters.
Some plugins also let you track 404 errors, but we’d recommend avoiding them for the reason we just outlined in the previous section (performance drag!).
If possible, try to redirect 404 errors to the proper spot. And for other errors, make sure you create a lightweight 404 page that won’t waste resources – the WordPress Codex has a good example of how to do it.
Let your site’s dynamic content shine
With the above tips in place, your dynamic WordPress site should be ready to load at rocket speed.
Not only will this benefit your users on the front-end, but it will also make your life easier as you work behind-the-scenes in a speedier WordPress dashboard.