MilesWeb
Leading Web Hosting Provider in India Since 2012.
Award-winning Web Hosting Company
Everything that you need to build, host and manage a website is available at just 99/mo

How To Set Frequency Of WordPress Heartbeat And Limit Executions?

The WordPress 3.6 version launched the WordPress Heartbeat API. WordPress Heartbeat API enables the communication of your browser and the server while you are logged into the WordPress admin panel. This feature enables WordPress to manage various aspects like letting the other author know that a particular post is being edited by some other user, the plugins can also use the script executions and thereby you can get notifications in real time etc.

Even though the WordPress Heartbeat API looks like a great feature, it might cause some issues in some situations. The Heartbeat makes checks at different time periods on different pages of your website – like for the post edits, it makes a check in every 15 minutes and on the Dashboard, the check is made every minute etc. Every ‘tick’ made by the Heartbeat creates a POST request that adds to the number of your executions and it also adds to the CPU time used.

The WordPress Heartbeat feature makes use of the wp-admin/admin-ajaz.php file in order to make the AJAX calls. If you notice that a large number of POST requests are generated by that file, it means that you have to limit the work of Heartbeat or you need to stop it completely.

How To Limit Heartbeat?

It is possible to limit the execution frequency of WordPress Heartbeat. This can be done by making use of a plugin known as ‘Heartbeat Control’.

  • Install the Heartbeat Control plugin and activate it
  • Now go to ‘Settings’ and click on ‘Heartbeat Control Settings’
  • From the ‘Heartbeat Behavior’ drop down menu, select ‘Modify Heartbeat’
  • Select all the ‘Locations’
  • From the ‘Frequency’ slider, select 60 or above
  • Save the settings

When the settings are saved, you will override the Heartbeat execution frequency that is set by default. The frequency will be set to the value that you set through the Frequency slider.

How To Disable Heartbeat?

You can disable WordPress Heartbeat by selecting the option ‘Disable Heartbeat’ from the ‘Heartbeat Behavior’ drop down menu and enable all the ‘Locations’. This will disable the use of Heartbeat feature on all the pages of your website.

How To Stop Heartbeat Completely?

If you no longer wish to work with the WordPress Heartbeat feature, you can stop it completely. For doing this, you have to edit the ‘functions.php’ file of your theme and paste the lines mentioned below right after opening the ‘<?php’ tag:

add_action( ‘init’, ‘stop_heartbeat’, 1 );

function stop_heartbeat() {

wp_deregister_script(‘heartbeat’);

}

This will completely stop Heartbeat from working on your website and it will no longer add to the number of executions and the CPU time utilized for your account.

Ujwala

My aim is to create enriching content on topics related to SEO, web hosting and social media. The idea is to elevate the readers to new levels of usability, accessibility and understanding.

Leave a Reply

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