WP-Cron: What it is and how to set it up correctly

WP-Cron is essential for WordPress and WooCommerce, but it may be slowing down your site. Find out how to activate it, optimize it and even replace it with a Cron Job on the server to improve performance.

WordPress relies on a system called WP-Cron to perform scheduled tasks automatically. These tasks include publishing scheduled posts, checking for plugin updates and sending emails. In WooCommerce, WP-Cron also manages important actions such as finalizing orders, updating stock and synchronizing with marketplaces.

Unlike the traditional server Cron Job, WP-Cron doesn’t run constantly at fixed times. It is only triggered when someone accesses the site, which can cause delays on sites with little traffic or overload on heavily visited sites.

How to activate or deactivate WP-Cron

By default, WP-Cron is already activated in WordPress. However, if you need to activate it manually, just make sure that the following line is not in the wp-config.php:

define('DISABLE_WP_CRON', true);

If this line is present, WP-Cron is deactivated. To activate it, simp ly remove it or set it to: false:

define('DISABLE_WP_CRON', false);

Caso seu site tenha tráfego alto, é recomendável desativar o WP-Cron interno e configurar um Cron Job no servidor, para que as tarefas sejam executadas de forma programada e sem depender do tráfego do site.

How to Limit Scheduled Actions in WooCommerce

If you use WooCommerce, you may have seen messages like:
“Maximum simultaneous batches already in progress (1 queue). No actions will be processed until the current batches are completed.”

This is because the WooCommerce Action Scheduler limits the number of simultaneous processes. To increase this limit, add this line in the wp-config.php:

define('WP_ASYNC_REQUESTS_CONCURRENT_LIMIT', 3);

This code allows up to 3 simultaneous processes. If your server is robust, you can test higher values, such as 5.

WP-Cron is essential for WordPress and WooCommerce to function, but it may need tweaking to improve performance. If your site has low traffic, a Cron Job on the server may be the best solution. Also, if you experience slow order processing in WooCommerce, adjusting the limit on simultaneous actions can optimize performance.

With these settings, your site will be faster and more efficient!

See you next time!

Anúncio
Categorias

Leave a Comment