WordPress Optimization

There are several improvements that can be done to optimize WordPress for large sites.

Use The System Cron

WordPress has a task scheduler called wp-cron. It checks if tasks are ready to be run on each page hit. This is overkill. We can have the operating system cron system run wp-cron to lessen the tasks done for each page hit.

It’s a 2 step process. First setup your system cron to call wp-cron.php, then configure wordpress not to run wp-cron for page hits.

Hooking WP-Cron Into the System Task Scheduler

I set mine to run every 5 minutes. This should be plenty for most people:

*/5 * * * * wget https://www.example.com/wp-cron.php

Then add this line to your wp-config.php:

define('DISABLE_WP_CRON', true);

PostMeta Database Caching

Check if you have wp_postmeta meta_key’s larger than 191:

SELECT MAX(LENGTH(meta_key)) FROM wp_postmeta;

(adjust for different wp_ prefix values or multisite tables)

If it’s below 191, then alter the table:

ALTER TABLE wp_postmeta MODIFY meta_key varchar(191);

Reference: https://core.trac.wordpress.org/ticket/33885

Heartbeat Control

Install the Heartbeat Control plugin. Limit the heartbeat to only run on pages/posts in 60 second intervals.

Fluff

The WP Disable plugin has a long list of fluff that it will disable. Emojis, gravitars, etc.

 

OnSiteWP