New Feature Announcement: Master Your Email Delivery with the Mail Delivery Center

Enhancing WordPress Performance: Disabling WP-Cron for Faster Load Times

WordPress is a powerful platform, but like any software, it requires regular maintenance to perform optimally. One such maintenance task involves cron jobs, which are scheduled tasks that WordPress uses to perform various functions. However, the default WordPress cron handler, WP-Cron, can sometimes slow down your site. This guide will show you how to disable WP-Cron and use a system cron job instead for improved performance.

Understanding Cron Jobs in WordPress

Cron jobs are essential to WordPress, allowing tasks to be scheduled at specific times, dates, or intervals. These tasks can include publishing a scheduled post, checking for updates, or activating a backup plugin on a set schedule.

WordPress uses a built-in cron handler, WP-Cron, to simulate system cron functionality. However, WP-Cron can potentially slow down your site, especially if it receives high traffic.

The Performance Impact of WP-Cron

WP-Cron isn't a true cron job; it's a workaround created by WordPress to emulate what a system cron does. WP-Cron doesn't run continuously. Instead, it's triggered on every page load, which can cause problems for high-traffic sites. If a site lacks sufficient PHP workers, a request might come in, WordPress will initiate the cron, but the cron has to wait for the worker, resulting in delays.

For low-traffic sites, schedules could be missed because no one has loaded a page. A more efficient approach is to disable WP-Cron and use the system cron instead. This method operates on a pre-defined schedule and is even recommended in the official Plugin handbook.

Disabling WP-Cron

To disable WP-Cron, insert the following code into your wp-config.php file, just before the line that says "That's all, stop editing! Happy blogging." This action prevents WP-Cron from running on page load, but not when you call it directly via wp-cron.php.

define('DISABLE_WP_CRON', true);

Scheduling System Cron

To schedule a system cron job, follow these steps:

  1. Log in to your cPanel account and navigate to the 'Cron Jobs' option in the Advanced section.
  2. In the 'Add New Cron Job' section, select a schedule. Your hosting provider likely has a limit on the frequency of cron jobs. Twice per hour is a common setting for shared hosts.
  3. Enter the following command, replacing https://domain.com with your domain name. This command might vary slightly based on your hosting configuration. Then click on "Add New Cron Job."
wget -q -O - https://domain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1

Note: The >/dev/null 2>&1 part of the command suppresses email notifications.

By following these steps, you can optimize your WordPress site's performance by replacing WP-Cron with a system cron job. Remember, regular maintenance is key to keeping your WordPress site running smoothly.

  • 310 Users Found This Useful
Was this answer helpful?

Related Articles

 Connect to your server via SSH

SSH allows secure file transfer and remote logins over the internet. Your connection via SSH is...

 How to force your site to use SSL (HTTPS) using

First of all, you will need to install an SSL certificate to your siteOnce your certificate is...

 How do I change PHP versions, or change my PHP settings / config?

The process of setting your PHP version and the 'variables' (such as memory_limit values) differs...

 How do I install a free SSL via cPanel?

Installing an SSL certificate in cPanel is easy! Best of all, it's free with WebGee!Important:...

 How to send emails in WordPress using the WP SMTP Mail plugin

Instead of using the default PHP mail() function, you can send emails using our SMTP services via...

Powered by WHMCompleteSolution