Reducing WordPress’ Memory Usage (Updated 2018)

/ Wordpress / by Paul Robinson / 0 Comments

It has been quite a while since the last tutorial on reducing WordPress’ memory usage was published. Since then a lot has changed. WordPress has received more features and is now well on the way to receiving Gutenberg.

With that in mind I think it is time to take an updated look at what you can do to reduce your WordPress based website’s memory usage.

Minimize Plugin Use

First up is a classic. Run as few plugins as possible. It might seem like an obvious tip, but not everyone realizes that plugins can increase your memory use by quite a large amount. For example, a small plugin like WordPress Zero Spam increases memory use by a small amount, but a larger plugin like WooCommerce increases it by a fairly large amount.

If a plugin is required for certain functionality then removing that plugin is not an option. I would recommend looking at the final option in this article if that seems to be your case.

Implement Caching

Reducing WordPress’ memory usage is not really the goal when implementing a caching system. Instead, caching is used to reduce the concurrent memory usage of the WordPress.

For those unfamiliar caching is a fairly simple concept. WordPress takes care of generating the page you requested and as such it uses server memory in the process. Caching allows the page to be generated once and the cache then saves that copy so that it can be served to other visitors without having to recreate it.

Don’t let WordPress eat all your server’s memory!

Be wary though, not all caching systems are the same. If you want to save the most memory you should look for one that completely removes the need for PHP to get involved at any stage. Ideally your cache should be serving a flat HTML file. Some plugins to try are Hyper Cache, WP Fastest Cache, W3 Total Cache, and WP Super Cache.

I have moved away from W3 Total Cache and WP Super Cache recently. W3 Total Cache can be difficult to get working correctly on Nginx and I found WP Super Cache to still be invoking PHP even when setup correctly with Apache rules (during client work).

My favorite cache at the moment is the native Nginx FastCGI cache. Check out my tutorial on setting up the Nginx FastCGI cache and using it with WordPress if you have the option to use it on your server.

Remove Visitor Login Features & Dynamic Content

This suggestion is completely reliant on having caching implemented. As metioned caching saves a copy of the generated page to serve to others thus bypassing the need to recreate the page from scratch.

However a problem occurs with some of WordPress’ dynamic features. If you are logged in, or you leave a comment, most caching systems are configured to stop serving you a cached copy. The server will instead always generate a fresh page for you.

With this in mind, and provided you don’t need the features, reducing WordPress’ memory usage can be achieved by disabling the ability for general visitors to register/login and also comment. If you still truly need commenting then you might look into a third-party alternative like Disqus so that your server is not processing the comments.

Disable XMLRPC Access

When trying to resolve memory issues XMLRPC can be easily overlooked. Its main purpose is to allow you to use the WordPress app via smartphone, power trackbacks/pingbacks and I believe some Jetpack features.

XMLRPC can be a big contributor to memory issues as it is often targeted by denial of service attacks. It is unable to be cached and so every request made to the file uses memory. Left unchecked it can quickly exhaust all available memory.

The best option is simply to disable access to the file. You can do this in a number of ways. A plugin like Disable XML-RPC is a quick and easy solution, but it does add 1 more plugin which you should try to avoid.

My preferred option is to disable it by blocking requests via your web server. In Apache this might look like:

Nginx could use something like this:

Accepting The Inevitable

If you have tried the tips given here, looked at other tips around the internet, and are still running into issues with server memory it might be time to accept the inevitable. You might need a better server.

Let’s face it, shared hosting that isn’t optimized for WordPress is pretty awful. About 10 years ago it was all I used and memory issues were always a problem, even with my small stats of 100 – 200 visits per day.

Now great hosting is available without breaking the bank. I recommend SiteGround’s WordPress hosting to my clients as they have always been great to work with and are very helpful. Their hosting in addition to my Maintenance services make sure your site will always be up-to-date and working at it’s best.

More adventurous types might want to try managing their own server. If that sounds like you then I would highly recommend Digital Ocean. The cheapest droplet they offer is more than enough for most and can scale very well when setup with caching.

Hopefully this post has given you a few tips on how to reduce your server’s memory use or maybe it has made you realize you need to look at moving to a new server? Regardless I hope it has been helpful and if you do need to move to a new server, consider getting in touch as I can help with that!

This post contains affiliate links. If you were to purchase a hosting plan or a droplet after clicking a link I would receive monetary credit from SiteGround or Digital Ocean.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

I'll keep your WordPress site up-to-date and working to its best.

Find out more