Wp-cron.php as performance eater

Regular readers already know it: I test and try out an incredible amount of things here. Especially when it comes to WordPress performance, I really blossom, because it has become a kind of passion of mine. WordPress is inherently sluggish and partly illogical, but it also has quite special and high demands on the hardware, so it's good to tune and optimize a little bit to avoid performance eaters. One of the naturally occurring performance eaters in WordPress is the file wp-cron.php in the root directory of the installation. The wp-cron.php actually only regulates constantly occurring tasks, is a kind of cronjob, but unfortunately does not work exactly like this. The problem: WordPress calls the wp-cron.php at each page request and then checks whether a scheduled task may exist. For example, whether a planned post should be published, or an update for WordPress, a plugin, or the themes is available. This is quite useless and unfortunately also eats a lot of performance from the server and should therefore be deactivated. You can do this in the wp-config.php with the command "define('DISABLE_WP_CRON', true);".

Planned contributions with Cachify

The WordPress Caching Plugin Cachifyfrom Sergei MüllerIn HDD mode (i.e. the hard disk cache), the PHP interpreter is not started, which brings performance, but also inevitable disadvantages. Scheduled tasks, including scheduled posts, are no longer executed correctly. Why? Because WordPress uses the wp-cron.php with every single page request and which is no longer possible without starting the PHP interpreter. For the performance of WordPress this is fantastic, you can't say it any other way, but for all professionally managed blogs it is a nightmare. They can't plan posts anymore, because WordPress won't publish them as planned, at least as long as Cachify runs in HDD mode. A problem, because hardly any blog can do without planning. A remedy is a real cronjob, which can wp-cron.php regularly and thus makes the planned tasks possible again. This is actually quite simple, but Cachify still lacks a publicly available manual for it.

Creating a Cronjob for Cachify

The advantage of a manually stored cron job is that the wp-cron.php is no longer constantly called up. So instead of checking every time the page is called to see if any scheduled tasks exist, the wp-cron.php is only started at certain intervals in a real cronjob of the server. This reduces the requests and demands of WordPress significantly, which in turn increases the performance enormously and reduces the general load on the server. Here you can choose how often you want to start the manually created cronjob. You can run it every minute or every 5 to 15 minutes. If you don't run it every minute, scheduled posts will simply be released a little later. So if an article is scheduled to run at 11:01 am, it may not be released until 11:05 am, because the cronjob only runs every five minutes. This is not a problem, unless you place a lot of emphasis on the exact publishing times of your articles.

Creates a cronjob with the following command (change URL!):

wget -q -O - >/dev/null 2>&1

Performance through Cronjob

The only thing you have to decide freely is time, as mentioned above. Starting the cronjob every minute is completely unnecessary, also because planned posts can be activated a few minutes later. Better protect your server and increase the overall performance by using the wp-cron.php of WordPress only every 5 or 15 minutes. This is sufficient and is immediately noticeable on the server, because even without this setting WordPress is often not very squeamish with the resources and therefore queries its virtual cron jobs continuously. A very simple and effective method to relieve the server, but also to get even more performance out of WordPress in general. For Cachify, this way is also absolutely necessary so that planned tasks and scheduled articles are executed or published as before.

About Christian

My name is Christian and I am co-founder of the platform fastWP. Here in the magazine I am responsible for the more "technical" topics but I like to write about SEO, which has been my passion for over 10 years now.

Leave a Comment

Your email address will not be published. Required fields are marked *