The Case for Disabling WP-Cron

The Case for Disabling WP-Cron

WP-Cron is a built-in WordPress feature for running scheduled tasks and time-based processes. The trigger for running WP-Cron is based upon page load. WP-Cron is not a true cron job, and used by default as a failover when setting a real cron job is not permitted. It’s useful in that event, but if you have the ability to set a real cron job, it would be advantageous for many reasons.

With WP-Cron, if your WordPress website doesn’t have enough traffic to trigger tasks in a timely manner, then your tasks will fail to run at the prescribed time, and there will be a backlog of tasks to process until the next page load. For newer WordPress websites, this may not be a big deal. However, as you grow and include more and more plugins that are dependant on timely task processing, your WordPress website may run into issues due to delayed task processing.

Furthermore, in the event of a backlog of tasks to process, the next visitor who lands on your website will end up triggering this backlog, and will experience an increase of load time. How much of an increase in the load time depends on the amount and intensity of the tasks to process. Some tasks may require more resources than others to fully process. With a backlog of tasks, it’s possible that a large amount of tasks to process may run into run time issues, and fail to fully process. This could cause further issues with the unfinished processes.

Speaking of load time issues – WP-Cron is executed on every page load in order to check if a task is due for processing. This action may be insignificant when no tasks are present, but on highly trafficked websites, WP-Cron unnecessarily adds load on the server for each and every page load.

Disabling WP-Cron and setting up a cron job will solve all of these issues. All tasks will be processed in a timely and consistent manner regardless of traffic automatically in the background. Therefore, there will not be a backlog of tasks to process. Run time issues will be minimized. Visitors will never experience an increase of page load time due to triggering any tasks. WP-Cron will not run on every page load, and therefore increases performance.

So, what interval should your cron job run? That depends on a lot of factors. Some hosts have limits on the interval a cron job can run. Be sure to check with your host before setting an interval that is shorter than permitted. I would recommend at least 15 minute intervals if your host will allow. However, there are instances where shorter intervals between cron jobs are warranted.

This article will not go into the technical implementation of disabling WP-Cron, and setting up a cron job. There are a multitude of well written articles out there that do an excellent job of explaining these processes. It’s time to include disabling WP-Cron and setting up a cron job as part of your WordPress installation process.