Start a Project

faster wordpress websites by disabling wp-cron

Karl – a web developer with Wibble web design Belfast
By Karl Proctor 13 June, 20236 MIN READ
Fast WordPress websites by disabling WP-Cron - Wibble Web Design and Development

WordPress Site Speed & SEO

Site speed is a significant ranking factor in terms of search results, making it even more important if you have a website and want it to perform well in terms of SEO. Your site speed could be the difference between your website and a competitor’s website appearing first for a given search. There are, of course, other factors to keep in mind, such as technical SEO and on-page content optimisation, but more than ever you also need to consider how fast your site is.

Improving site speed

Wibble are a leading Northern Ireland web design studio and we are constantly researching more ways to improve site speed for our clients’ WordPress sites, and recently, we have been researching the benefits of replacing the WordPress cron system with a server-based cron. This is a relatively simple process, and it can free up your website to focus more on serving the actual web pages as quickly as possible, without using user requests to run background tasks as well.

What is the WP Cron

Before we start, some clarification on what is the WP Cron could help. The WP Cron, or WordPress Cron, is a scheduling system within WordPress itself. It allows the automation of tasks like publishing scheduled posts, checking for updates etc. Unlike traditional cron jobs that run at the server level, WordPress Cron relies on web requests triggered when a user visits the site – so these tasks only run when a human is on the site.

Simplifying Cron Task Management and Boosting Performance

This is the process for disabling the WP Cron, and enabling a server cron to handle the background tasks:

  1. Disable the WP Cron system.

    This can be achieved by adding this line of code to your wp-config.php file, just before the line that says “That’s all, stop editing! Happy blogging.” :
    define('DISABLE_WP_CRON', true);
    Once this is added, WordPress will no longer trigger the cron system when a user visits the site. This will therefore require another method to execute the required tasks, so we’ll set that up next.
    Disable WP Cron via Terminal & nano command on wp-config.php file

  2. Add a Server Cron that will target WP CLI

    For this step, we will be adding a server-based cron that executes the necessary tasks for WordPress. You can set this cron to any interval, but we typically recommend a value of every 15 minutes, which is sufficient to handle all required tasks. If needed, this interval can be adjusted to run more frequently for certain sites. To implement the server-based cron, you’ll need to add the following code to your hosting provider:
    */15 * * * * cd ~/public_html && wp cron event run --due-now > /dev/null 2>&1

    For websites using WooCommerce, there is a system called Action Scheduler, which functions similarly to WP Cron. To utilize a server-based cron for this system, you can use the following line:
    */15 * * * * cd ~/public_html && wp action-scheduler run > /dev/null 2>&1

    Another advantage of using a server-based cron is that it always runs on time. Tasks won’t get backed up or delayed if website traffic fluctuates and decreases during certain periods. The WP Cron system relies on user visits to trigger the cron events. Consequently, during quieter periods, tasks can be delayed and accumulate until a user visits the website. When a user does visit, the site has to execute all these delayed tasks while serving the requested page.

    This is how it looks to add a cron in our hosting environment. Your setup may be different, but most hosts will have support information on how to add this.
    Adding cron with Cloudways

  3. Test!

    There’s technically only two steps, but testing is key in everything that is considered a big change. To make sure that everything is working ok, you’ll want to test to website and check that everything is getting run properly. This is something that we would carry out, once we enable this feature for a client’s website. We do these steps, and run the testing for this, so you don’t have to worry about it.

Offloading Cron tasks to the Server

Implementing a server-based cron system not only simplifies the management of cron tasks but also yields numerous benefits for site speed and server performance. By offloading the responsibility of executing cron tasks from the client-facing side to the server, you can experience significant improvements in both areas.

Optimising Resource Allocation

When the server directly handles cron tasks, it frees up valuable resources on the client-facing side. Instead of consuming server resources and processing power to execute background tasks, your website can focus on its core functionality, efficiently serving web pages to users. This optimized allocation of resources enhances the overall speed and responsiveness of your site, ensuring a seamless browsing experience for your visitors.

Independent Task Execution

Moreover, with a server-based cron, the execution of tasks is no longer dependent on user visits to your website. Unlike the traditional WP Cron system, which requires user interaction to trigger cron events, a server cron runs independently and consistently at the specified intervals. This ensures that critical tasks are executed promptly, regardless of fluctuations in website traffic or user engagement. Consequently, you can prevent delays and accumulations of tasks during quieter periods, minimizing the risk of performance bottlenecks and ensuring the smooth functioning of your website at all times.

Optimising Site Speed and Server Heath

By adopting a server-based cron system, you are proactively optimizing your site’s speed and enhancing overall server health. The separation of cron tasks from the client-facing side reduces the burden on your website’s resources, allowing it to operate more efficiently. With improved site speed, your web pages load faster, resulting in enhanced user satisfaction and engagement. Additionally, by ensuring timely execution of tasks, you can maintain a well-organized and responsive website, delivering a seamless user experience and gaining a competitive edge in search engine rankings.

Unlocking the Full Potential of Your Website

In summary, integrating a server-based cron system into your website’s infrastructure is a strategic move that positively impacts performance, speed, and overall user experience. By leveraging the capabilities of your hosting environment to handle cron tasks, you can unlock the full potential of your website, focus on its primary function of serving content, and elevate your online presence to new heights.

Help with a slow WordPress site

Wibble have been a WordPress web design studio since 2013 and have worked on hundreds of bespoke WordPress sites with a key focus on site speed and performance. if you need help with a slow WordPress site, contact Wibble, a web design firm based in Belfast in Northern Ireland, to help with your slow website.

Share this blog post

Karl – a web developer with Wibble web design Belfast

Karl Proctor

More from author