Your Search Bar For Side Hustle Tips

What Is Wordpress Heartbeat Api

|Blog Argute

WordPress Heartbeat API is a built-in feature that lets WordPress communicate between your browser and your website while you work. It runs quietly in the background, sending periodic requests so the site can save changes, check whether another person is editing the same post, and update certain dashboard information without requiring you to reload the page.

If you have ever seen a warning that another user is editing a post, or noticed that a draft was saved automatically, you have likely benefited from the WordPress Heartbeat API. Understanding how it works can help you troubleshoot editor issues and manage server load without disabling useful features.

What Is the WordPress Heartbeat API?

The WordPress Heartbeat API is a system for sending and receiving data between the WordPress admin area and a user’s web browser at regular intervals. It was introduced in WordPress 3.6 and is used by WordPress core, themes, and plugins to support updates that happen in the background.

Despite the word “API” in its name, Heartbeat is not the same as the WordPress REST API. It uses Ajax requests, commonly handled through WordPress’s admin-ajax.php file. The browser sends a request, WordPress processes it, and the server returns a response. This exchange is repeated while the relevant page remains open.

The API is called “Heartbeat” because it regularly checks in with the server. A request might ask the site to save editor content or check whether a post is locked. The request and response can also carry data added by plugins, allowing them to update features without refreshing the entire page.

How Does the WordPress Heartbeat API Work?

When a WordPress screen loads, WordPress can add a JavaScript process that sends Heartbeat requests at a set interval. The exact interval may depend on the screen, WordPress configuration, browser behavior, and any plugins or custom code that change it.

Each request typically includes information about the current screen and any data that needs to be sent. WordPress checks the request, runs the relevant processing, and sends a response back to the browser. JavaScript on the page can then use that response to update the interface or take another action.

For example, a post editor may send information about the content currently being edited. WordPress can use it to save a draft or refresh the post-lock status. The user can continue working without manually submitting the post or reloading the page.

Heartbeat requests are not the same as a visitor loading a page. They are background requests made by an open browser tab. As a result, many open WordPress tabs can create more requests than a single tab. On a busy or resource-limited hosting account, this activity may contribute to server load.

What Does the Heartbeat API Do?

WordPress uses Heartbeat for several practical features. The exact behavior depends on the page you are using and the plugins installed on your site, but common uses include:

  • Automatic saving: The editor can save draft changes periodically, helping reduce the risk of losing work if a browser closes or a connection fails.
  • Post locking: WordPress can detect when another user is editing the same post and help prevent conflicting changes.
  • Editor status updates: The editor can receive information about the post or editing session without a full page reload.
  • Dashboard updates: Some admin screens and plugins use Heartbeat to refresh information or display notifications.
  • Plugin features: Plugins may use Heartbeat to exchange small amounts of data for chat, monitoring, workflow, or other interactive tools.

Heartbeat does not automatically save every kind of change everywhere in WordPress. A feature must be designed to use the API, and its behavior can vary by editor, plugin, and site configuration. For important work, it is still sensible to save or update manually when appropriate.

Where Is Heartbeat Used?

Heartbeat is most noticeable in the WordPress administration area, especially while editing posts and pages. It can also be used on other admin screens. Depending on the active theme and plugins, requests may be added to front-end pages as well, though that is not automatically necessary for every public page.

The WordPress editor is a particularly important use case. If two editors open the same post, WordPress needs a way to communicate that the post is already being edited. Heartbeat helps maintain this status and supports the lock notice shown to the second editor.

Plugins can also attach their own data to Heartbeat requests and responses. This flexibility is useful, but it means that a site’s Heartbeat activity may not come from WordPress core alone. If you are investigating frequent requests, check which plugins are using the API before changing its behavior.

Does the WordPress Heartbeat API Affect Performance?

Heartbeat makes recurring requests, so it does use some server resources and browser activity. On most modern WordPress sites, the impact is small. However, the effect can become noticeable when many users keep admin pages open, when a hosting plan has limited resources, or when a plugin performs expensive work for every request.

For example, a site with several editors working at once may receive more Heartbeat requests than a site with only one administrator who logs in occasionally. Each open tab can continue communicating with the server. A plugin that adds slow database queries to every Heartbeat response may increase the cost of those requests further.

Frequent requests do not automatically mean Heartbeat is the cause of poor performance. High server load can come from many sources, including uncached pages, slow database queries, heavy plugins, traffic spikes, or limited hosting resources. Use server logs or a suitable performance-monitoring tool to identify the actual cause before changing settings.

Should You Disable the Heartbeat API?

In most cases, you should not disable the WordPress Heartbeat API sitewide. Turning it off can interfere with automatic saving, post locking, and plugin features that rely on background communication. The result may be lost edits, conflicting changes, missing updates, or a feature that no longer behaves as expected.

If Heartbeat requests are contributing to a performance issue, consider adjusting the interval or limiting where the API runs rather than removing it completely. For instance, a site owner may choose to reduce unnecessary activity on screens that do not need frequent updates while keeping the editor’s important functions available.

Before changing Heartbeat settings, consider these steps:

  • Check whether the requests are actually causing a significant load problem.
  • Identify plugins that add work to Heartbeat requests and test them individually.
  • Adjust request frequency carefully instead of disabling the feature everywhere.
  • Keep Heartbeat active where automatic saving or post locking is important.
  • Test changes on a staging site, especially if multiple people edit content.

Performance plugins sometimes offer controls for Heartbeat frequency or location. These can be convenient, but settings vary between plugins and WordPress versions. Review the plugin documentation and test the editor after making a change.

Can You Change the Heartbeat Interval?

Yes. The Heartbeat interval can be adjusted using WordPress settings, plugins, or custom development. The interval determines how often the browser checks in. A longer interval usually means fewer requests, while a shorter interval allows information to be exchanged more frequently.

There is no single ideal interval for every website. A site with several people collaborating in the editor may need frequent updates to support a smooth workflow. A site with no need for real-time admin updates may be able to use a less frequent interval on selected screens. Changes should balance responsiveness with server capacity.

Developers can also interact with Heartbeat using WordPress hooks and JavaScript events. On the PHP side, actions such as heartbeat_received let code respond to received data, while the heartbeat_settings filter can be used to modify Heartbeat configuration. In JavaScript, events such as heartbeat-send and heartbeat-tick can be used to add or handle data in the browser.

Custom code should be written and tested carefully. Heartbeat requests are part of an ongoing browser-server exchange, so poorly designed code can add unnecessary database work or expose information that should not be returned. Validate incoming data, check permissions where needed, and avoid sending sensitive content in a response.

How to Troubleshoot WordPress Heartbeat Problems

If automatic saving or post locking is not working, first check the basics. Confirm that your browser has a stable connection, that the user has permission to edit the content, and that no browser extension or security tool is blocking requests. Then review any recent plugin or theme changes.

For persistent problems, a developer can inspect browser network activity to see whether Heartbeat requests are being sent and whether they return errors. Server logs may reveal PHP errors or timeouts. If the issue began after installing a plugin, temporarily deactivate it on a staging site to determine whether it affects the request or response.

When testing changes, use more than one account if you need to verify post locking. Open the same post in separate sessions and confirm that WordPress displays the expected editing notice. Also test automatic saving by making a small draft change and checking that it is retained.

WordPress Heartbeat API Best Practices

For most site owners, the best approach is to leave the default behavior alone unless there is a clear performance or functionality reason to change it. WordPress core uses Heartbeat to support important editing workflows, and disabling it broadly can create problems that are harder to spot than a modest increase in requests.

If you manage a high-traffic or resource-constrained site, measure first and make targeted adjustments. Keep essential editor functions intact, review plugins that use Heartbeat, and retest after updates to WordPress or your plugins. A setting that helps one site may not be appropriate for another.

Conclusion

The WordPress Heartbeat API is a background communication system that helps WordPress and the browser exchange information while a page is open. It supports features such as automatic draft saving, post locking, and plugin updates, primarily through recurring Ajax requests.

Although Heartbeat can contribute to server activity, it is usually a useful part of WordPress rather than a feature that should be removed by default. If you suspect it is affecting performance, identify the source of the requests, measure their impact, and adjust the frequency or scope carefully. That way, you can manage server load while preserving the editing tools that make WordPress easier to use.