I know you! You're a WordPress vigilante when it comes to speed. You want it fast, baby. You use a Content Delivery Network (CDN) to speed up your image loading times. Your images are carefully optimized for small file sizes and fast loading. You spent hours researching, testing and setting up your speed caching plugin. But the speed you seek is still ever elusive. Plus, your web host has warned you about the heavy resource demands of your website every time some real traffic finds your site. What's going on? Here's a problem that often flies completely under the WordPress radar. Cron jobs. Cron what... What are Cron jobs?
Cron Jobs and Why They're A Big Deal in WordPress
Basically, a Cron is a scheduled repetitive task. In a Linux environment (the web host operating system that runs your WordPress website), a Cron is often used by many WordPress plugins to run necessary tasks on a daily schedule. A cron may update files or modify a database at scheduled times. However, here is a problem unique to WordPress:
WordPress has its own cron program named WP-Cron that is used by many WordPress plugins to start scheduled tasks. The difference between Wp-Cron and the Linux Cron program is that WP-Cron runs every time someone visits your website. The Linux Cron runs on a time schedule. WP-Cron may become a problem when your website gets lots of visitors. In essence, it starts to run each time a new person visits your website. The web page will not load until the cron jobs initiated by WP-Cron has finished running. If you have lots of plugins installed on your WordPress website you will most likely have lots of cron jobs that run every time someone visits your website. Your WordPress web pages load very slowly as they must wait for the cron jobs to complete their processes before being seen by a visitor.
Excessive cron jobs demand lots of server resources (they slow down the computer your website is hosted on). If your WordPress website is running in a shared server environment (many websites sharing the same server), then cron jobs may slow down your website and others that share the same server. If you're not sure if you are running on a 'shared server environment,' then you are. It's the most common and inexpensive form of hosting. This is why web hosts often ban certain WordPress plugins known to be resource hogs (related posts plugins are notorious for this).
But wait, there's more! If you have tested and deleted a number of plugins on your WordPress website in the past, consider this: Some plugins, leave behind active cron jobs even after they are deleted. Those cron jobs continue to run on schedule after the plugin is long gone, slowing down your WordPress website in the process! The very popular Jetpack plugin is known for this. Even if you deleted that plugin, it leaves behind resource hogging cron jobs that run on endlessly, serving no meaningful function.
How I Discovered WP-Cron
I use a WordPress security plugin that has a live log feature allowing me to see statistics on visitors to my website in real time. I noticed that for every new visitor to my website, there was a number of cron jobs also loading. I did not know what a cron job was. I was also curious if this was the culprit behind my slow-loading web pages. So, I did my research and discovered the wonderful world of WP-Cron. If you face a similar issue, take heart! There is a solution.
How to Fix The Cron Job Problem
There are a number of complex solutions that involve some editing of files that is best left to more advanced webmasters. Here is a simple way to test and fix the problem. Do a search in the WordPress plugin directory for 'cron job.' You will find a number of plugins that allow you to see what cron jobs are running on your WordPress and to control when they run. These plugins will run cron jobs on a time schedule rather than every time someone visits your website. For example, you can schedule cron jobs to run every 15 minutes or once an hour. This greatly reduces web server demands that slowdown web page load times. If you discover cron jobs that are still running for plugins that have been deleted, they can be disabled or removed. Just be sure to choose a WordPress cron plugin that has a large number of users, is highly rated, and is compatible with the current version of WordPress.
This is a problem that is best tackled by someone with at least an intermediate knowledge of WordPress. If you have few or no plugins running on your website then this will most likely not be an issue. This may be a factor in your website slowness if you have five or more plugins installed, and have used or tested a wide variety of plugins in the past. -Don Peterson