CHT10

WordPress Heartbeat API: What is it and Easy Way To Control It

WordPress Heartbeat API What is it & How to Control it (Easy Way)

WordPress comes with the feature called heartbeat API which creates a communication channel between your hosting server and browser. However, there are a few drawbacks to this feature. It needs to be taken care of as it often generates a server load.

For this reason, hosting companies send a warning to those websites which do over CPU utilization of the hosting server and exceed a certain limit.

In case if you ignore this warning & don’t take any action, you have a risk of hosting termination by taking down your website offline. Moreover, some hosting companies also suspend accounts when going over the limit.

Thus, here we’ll discuss what wordpress heartbeat API is and how it affects the server resource utilization with some controllable steps.

What is WordPress Heartbeat API with functions?

WordPress Heartbeat is an API to offer real-time information on the wordpress dashboard by making communication protocol between browser and server. The heartbeat API sends pulses and triggers automatic events by using AJAX calls.

Here are some of the major functions of WordPress Heartbeat API:

  • Sync all the data between the server and WordPress dashboard.
  • Autosave a post in WordPress editor periodically while creating or editing posts based to the set period.
  • Get eCommerce sales data on the dashboard using plugins like WooCommerce.
  • Used to show notification on the WordPress admin dashboard.
  • Prevent post-editing of another writer/user using the post locking function. That means all authors will see a message that the post is locked by another author.

Why Controlling WordPress Heartbeat API is Important?

WHY CONTROLLING WORDPRESS HEARTBEAT API IS IMPORTANT

 

While wordpress heartbeat API sounds beneficial with a variety of functions, it often creates server problems. Thus, controlling it is very important to drop down the server load and to optimize wordpress performance.

Heartbeat API sends AJAX requests to the server using the “/wp-admin/admin-ajax.php“ file.

This can cause a large number of ajax requests sent to the hosting server, which results in high CPU utilization. The more the ajax requests will be, the higher will be the server load.

Since shared hosting offers limited server resources, they need to take action against your wordpress account because of high CPU usage.

As you reach your quota limit, there is a huge chance of account suspension by the company in such cases.

AdvertisementContinue Reading Below

Control WordPress Heartbeat API with Plugin

You can use the Heartbeat Control plugin to manage the limit of Heartbeat API requests sent to your server.

Navigate “heartbeat control” in the “Settings” menu of your wordpress and manage heartbeat API with 3 useful configurations within the plugin.

  • Heartbeat Behavior – this function allows you to enable heartbeat, disable heartbeat, or modify heartbeat.
  • Locations – here you can determine which area you want to control the API from, it provides you with three options: WordPress Dashboard, Frontend, and Post Editor.
  • Frequency – you can set the frequency of the number of callbacks you allow for each determined location from 15 to 300 seconds.

For instance, you can set the limit of the frequency of the Heartbeat API function to 200 seconds in Post Editor if you have multiple authors to work on the same wordpress site.

You can also set the value differently in each location you wish to control.

However, if you want to completely stop the wordpress heartbeat API, this plugin allows you to disable it. To do so, choose Disable Heartbeat in the Heartbeat Behavior section of the plugin.

Disable WordPress Heartbeat API without Plugin

If you don’t want to install a plugin for stopping WordPress Heartbeat API, you can add a simple code in the “functions.php” file of your theme to do so. In case you are the only person working with your WordPress site, here is how to manage WordPress heartbeat API using this code:


add_action( 'init', 'stop_heartbeat', 1 );
function stop_heartbeat() {
wp_deregister_script('heartbeat');
}

Think Again Before Stopping WordPress Heartbeat API

THINK AGAIN BEFORE STOPPING WORDPRESS HEARTBEAT API

 

Heartbeat API in WordPress carries out a few significant functions that you need to keep in mind before stopping heartbeat API.

Without the wordpress heartbeat API, the changes you’ve made in the post will be lost if you ever forget to click on the save draft button in the post editor.

Moreover, you’ll no longer be able to access the revision feature in WordPress.

With your installed WordPress plugins that are using heartbeat API, you’ll stop getting the real-time notifications and information features on your site.

However, if you’re working alone, and all of these functions do not matter much to you, you can go ahead to stop WordPress Heartbeat API. Otherwise, you might consider controlling the API instead.

2 thoughts on “WordPress Heartbeat API: What is it and Easy Way To Control It

  1. Hey there! I just wanted to ask if you ever have any issues with hackers?My last blog (wordpress) was hacked and I ended up losing months of hard work due to no back up.Do you have any solutions to prevent hackers

Leave a Reply

Review Details

×

    Get Free Audit Report