Let’s talk about WordPress and how to combat the slow website speeds that come with it.
Sure, plugins, JavaScript, heavy theme files, and other usability issues play a factor. But we aren’t going to go there today; today, we will talk about the built-in WordPress Cron Jobs, discuss what they do, and then show you how to disable them by using just a bit of technical intervention.
What is a WordPress Cron Job?
WordPress Cron Jobs are triggered events that process behind the scenes that help WordPress look for updates, check plugins, publish scheduled posts, etc.
Do you need them to run your site? Yes, I would say so, but the “everything in moderation” saying rings home in this case. You can utilize these scheduled events via your hosting service in a much more controlled and modest way.
Why are the built-in WordPress Cron Jobs a bad thing?
They suck the life from your website. When a visitor lands on your website or views a page, this triggers WordPress to run a Cron.
For example, you may have decided to install a backup plugin to back up your website and data automatically; let’s say you set this plugin to run once a day to backup your entire website. More often than not, this setting alone would likely reduce your website speed performance to a crawl during the 20 to 30 minute period while the website is backing up. Over time, plugins, applied settings, and functionality added to your WordPress website begin to stack up. You have Cron processes running for the majority of the day, leaving your website performance to suffer.
How to fix it?
Simple, what we want to do here is disable the auto Cron Jobs and then apply a setting via your website hosting service to allow the WordPress Cron Jobs to run once per day, preferably in the middle of the night.
- Step 1 – Disabling WordPress Cron Jobs
Open your wp-config.php file and add the below code to your file:
define('DISABLE_WP_CRON', true);
- Step 2 – Add a Manual Cron Job Via Your Website Hosting
If cPanel powers your website hosting service, log in and browse to the Cron Jobs area, then follow the prompts setting the specific frequency and time you want your Cron Jobs to run.
Add the command below:
cd /home/INSERTUSERNAME/public_html; php -q wp-cron.php
Where you see INSERTUSERNAME you will want to use the username utilized to login to your cPanel.