Back to Top

How to use WordPress Heartbeat API?

WordPress Heatbeat API Explained

I know it is too late to take WordPress 3.6 topic which HeartBeat API but Better late than never.As WordPress version, 3.6 was introduced a great new API which is known as Heartbeat API.This API is mainly useful to track changes, user sessions, revisions and automatic save content at some interval.Also send a notification about the expiration of login.However in some cases, it might increase the CPU usage and slow down the website.

Today we will learn more about WordPress Heartbeat API.You might have a question in mind about this strange name, Let’s understand that too.

What is Heartbeat API?

Heartbeat API name itself introduce us, mainly it is kind of pulse effect which processed to perform in some frequency.

Basically, it simply send AJAX requests automatically after a certain time(may be intervals of 15-30 seconds) to the server and trigger some events after receiving a response from the server. This action is performed very quickly and sometimes it crash the browser, but it helps to prevent the data loss by simultaneously editing of the post.

Disable HeartBeat API is recommended for your WordPress site if, you are facing resources issue.In some cases, The specific file admin-ajax.php call the WordPress heartbeat request and waits for an response from the server,sometimes responsible for increasing consumption of memory and CPU on the server due to frequent database calls compared to other requests which are not cached and slowed down your admin panel. At that time, It is necessary to Disable HeartBeat API.

NOTE: Once you disable HeartBeat API, It will turn off the autosave feature of WordPress. We have previously written about POST AUTOSAVE INTERVAL IN WORDPRESS.

How to Disable HeartBeat API?

To Disable HeartBeat API, You just need to write following line of code inside the active theme’s functions.php file.

Above line of code will disable HeartBeat API for the site except post.php,post-new.php and edit.php.This is the best way by adding few lines of code into WordPress file rather than installing the plug-in which might affect a site on upgrade.

How To Change the HeartBeat API frequency?

If you don’t want to disable HeartBeat API, You can change the frequency of it which slow the heartbeat call.Although, You can set the minimum 5 and maximum 60 seconds.Here is the example to set the time interval in which each pulse is executed.

Let’s take a look at how to limit WordPress Heartbeat API.

In the case of any unexpected query or issue, simply write in comment section.

Comments (1)

  1. Thanks for the explanation!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How to use Micro Data in HTML5

Posted on 9 years ago

Bhumi