WordPress Heartbeat API: What It Does and When to Limit It

Open a handful of admin tabs and leave them there for an afternoon. Every one of them is quietly polling your server. That is the Heartbeat API, and it is usually discovered through a host warning about admin-ajax.php rather than through anything visible in the browser.

The standard advice is to disable it. That advice is half right. Heartbeat is the transport under autosave, post locking, session checks, and nonce refresh, so switching it off everywhere trades a server cost for a set of failures that show up later and look unrelated.

This is what the tick actually does, how to measure it on your own site, and where the safe limits are.

What the Heartbeat API is

Heartbeat is a polling API that has shipped with WordPress since 3.6. The browser sets a timer, and when the timer fires it sends a POST to admin-ajax.php with action=heartbeat. The server runs whatever is hooked to heartbeat_received and heartbeat_send, then returns JSON. The browser fires an event with the response.

That is the whole mechanism. There is no socket, no long-lived connection, and no server push. It is a repeated HTTP request that happens to carry small pieces of state.

The name causes most of the confusion. Heartbeat sounds like a background service. It is a request from a browser tab, and it stops when that tab closes.

What the tick actually does

Three numbers explain the behaviour, and all three come from core rather than from a blog post.

  • 60 seconds is the default interval in heartbeat.js. That is one request per open admin tab per minute.
  • 120 seconds is the interval used when the tab loses focus. The comment in core is explicit about why: post locks expire after 150 seconds, so the slower tick still refreshes the lock in time.
  • 5 seconds is the “fast” interval, used for up to 30 ticks when something needs near-real-time updates. wp.heartbeat.interval( 'fast' ) is the call.

The plugin handbook describes the tick as running every 15 to 120 seconds. The default sits at 60 in current core, and the script accepts a range from 1 to 3600 seconds if a plugin changes it. The documented 15–120 band is the range you should stay inside unless you have a specific reason not to.

Each request carries the nonce, the current screen id, and a has_focus flag. That last one matters: a tab in the background is not treated the same as a tab you are working in.

What depends on it

The hooks tell you more than the marketing copy does. In core, the heartbeat response is used by:

  • wp_check_locked_posts and wp_refresh_post_lock, which drive the “someone else is editing this post” warning,
  • heartbeat_autosave, which is the classic editor’s autosave,
  • wp_auth_check, which shows the “your session has expired” dialog and lets you log back in without losing the screen,
  • wp_refresh_heartbeat_nonces, which refreshes nonces during a long admin session.

That list is why disabling heartbeat is not a pure performance win. Remove it and the editor stops warning you about a second editor, the session dialog stops appearing, and a screen left open for an hour starts throwing “the link you followed has expired” errors when you finally click Save.

Plugins add their own consumers. A backup plugin that shows progress, an SEO plugin that polls index status, or a custom dashboard widget can all be riding the same tick. Nothing in core tells you which ones are, which is why the measurement step below comes before the code.

It is an admin problem, not a front-end one

This is the correction that saves the most time. By default, Heartbeat loads in wp-admin through the authentication check. It is not part of the public front end unless a theme or plugin enqueues it there.

So the common advice to “disable Heartbeat for Core Web Vitals” is aimed at the wrong page. Your visitors are not making heartbeat requests. Your logged-in editors are, and they are doing it on a screen that page caching cannot help, because admin-ajax.php is not a cacheable page.

The cost is real on constrained hosting. Every heartbeat request bootstraps WordPress, loads plugins, and runs the callbacks, just like any other uncached admin request. The arithmetic is easy to do:

  • one tab, one hour: 60 requests,
  • three tabs, eight hours: 1,440 requests,
  • five tabs, eight hours: 2,400 requests.

None of those numbers is a benchmark. They are the request count the interval implies, and they are enough to explain why a host flags admin-ajax.php on a site with modest traffic.

Measure it before you change it

Open one admin screen, open the browser’s Network panel, and filter for admin-ajax.php. Click a request and read the payload. You are looking for action: heartbeat. The response is small JSON, and the timing shows how long the bootstrap took.

To see the interval the page is actually using, run this in the console on any admin screen:

wp.heartbeat.interval();

It returns the current interval in seconds. If a plugin has already changed it, this is where you find out before adding a second filter that fights the first.

Server-side measurement is less precise, and it is worth knowing why. The action parameter is in the POST body, so a normal access log records POST /wp-admin/admin-ajax.php without saying which action ran. You can count all admin-ajax POSTs as an upper bound:

awk '$6 ~ /POST/ && $7 ~ /admin-ajax\.php/ {n++} END {print n+0}' access.log

That number includes cart, search, and plugin endpoints, so treat it as a ceiling rather than a heartbeat count. For an exact count, the browser panel is the honest tool.

Three ways to limit it, safest first

1. Raise the interval

The least invasive change is a filter. It keeps every feature working and simply makes the check less frequent:

add_filter( 'heartbeat_settings', function ( $settings ) {
    $settings['interval'] = 120;
    return $settings;
} );

One hundred and twenty seconds is the top of the documented range and still inside the 150-second post-lock window. That is not a coincidence; it is the reason the unfocused tab uses the same number.

The trade-off is slower autosave and a slightly later lock warning. For most sites that is invisible. For a newsroom with several editors in the same post, it is the difference between a warning and a collision, so test it with two browsers before rolling it out. The heartbeat_settings reference documents the filter and the accepted values.

2. Disable it on screens that do not need it

The dashboard, the media library, and the posts list do not need autosave or post locking. The editor screens do. A targeted dequeue is safer than a site-wide one:

add_action( 'admin_enqueue_scripts', function () {
    $screen = get_current_screen();
    if ( ! $screen ) {
        return;
    }

    $quiet = array( 'dashboard', 'upload', 'edit-post', 'edit-page' );
    if ( ! in_array( $screen->id, $quiet, true ) ) {
        return;
    }

    // wp-auth-check depends on heartbeat, so remove both.
    wp_dequeue_script( 'wp-auth-check' );
    wp_deregister_script( 'heartbeat' );
}, 20 );

Two details matter here. The wp-auth-check script declares heartbeat as a dependency, so deregistering one without the other can leave a script that expects an object that is not there. And the screen ids above are the defaults; a page builder or an admin customiser can rename them, so check $screen->id on the screen you are targeting before trusting the list.

Keep post and post-new out of that array. Those are the screens where the heartbeat is doing the work you paid for.

3. Use a plugin if you would rather not maintain code

Heartbeat Control does the same two things through settings: a global interval and per-screen control. It is a reasonable choice for a site where nobody wants a snippet in functions.php, and it is easier to hand over to whoever maintains the site next.

The plugin does not change the underlying trade-off. It only makes the switch easier to find.

What breaks when you turn it off

If you disable Heartbeat everywhere, expect some combination of these:

  • the classic editor stops autosaving, so a crashed tab loses work,
  • the post-lock warning disappears, so two editors can overwrite each other,
  • the session-expired dialog stops appearing, and a long-idle screen fails on save,
  • nonces stop refreshing, which surfaces as “the link you followed has expired,”
  • plugin screens that poll for progress or status stop updating.

None of those failures announces itself as “heartbeat is off.” That is the trap. They look like editor bugs, plugin bugs, or a host problem, and the person debugging them has usually forgotten the snippet added months earlier.

When heartbeat is not the real problem

A slow admin is not automatically a heartbeat problem. If the dashboard takes four seconds to load before any poll happens, the tick is not the cause; the bootstrap is. The same uncached admin-ajax.php path that makes heartbeat expensive also serves every other admin request, so a slow database, a missing object cache, or a plugin doing heavy work on init will show up in exactly the same place.

The performance-first WordPress guide covers where the front-end wins actually come from, and the measured speed walkthrough shows how to take that baseline without guessing. The site functionality and speed check is the broader diagnostic when the admin is slow for reasons you cannot see. If the admin only feels heavy with several tabs open, heartbeat is a plausible contributor. If it is slow with one tab, look at the stack first.

Caching is worth understanding here too. A page cache does not touch admin-ajax.php, which is why cache plugins can improve the front end while the admin stays exactly as slow as before. Object caching and opcache help both, because they reduce the cost of the bootstrap rather than skipping the request.

A short checklist

When someone says the admin is slow, work in this order:

  1. Confirm the requests are heartbeat: Network panel, admin-ajax.php, payload action: heartbeat.
  2. Check the current interval with wp.heartbeat.interval() before changing anything.
  3. Raise the interval to 60 or 120 and leave the feature intact.
  4. Disable it only on screens with no autosave, lock, or session requirement.
  5. Test the editor with two browsers before calling it done.

That order fixes the common case without creating the uncommon one.

FAQ

What is the WordPress Heartbeat API?

It is a polling API that sends a request from an open admin tab to admin-ajax.php on a timer. Core uses it for autosave, post locking, session checks, and nonce refresh.

Does Heartbeat slow down my website for visitors?

Usually not. It loads in the admin, not on public pages, unless a plugin puts it there. If visitors are slow, look at the front-end stack before touching heartbeat.

What is a safe heartbeat interval?

Sixty seconds is the core default and 120 is the documented upper end. Stay at or below 120 so the post-lock refresh still lands inside the 150-second lock window.

Can I disable the Heartbeat API completely?

You can, and you will lose autosave, post-lock warnings, session-expired handling, and nonce refresh. Disable it per screen or raise the interval instead.

Does Heartbeat affect WooCommerce?

WooCommerce uses its own AJAX endpoints for most storefront behaviour, so heartbeat is rarely the reason a cart is slow. On a large store, admin-side polling is a smaller cost than the storefront and database work covered in the WooCommerce scaling guide.

Does Heartbeat keep running when the tab is in the background?

Yes, but at half the rate. The interval stretches from 60 to 120 seconds when the tab loses focus, and the script suspends the connection when the page is unloaded.

Is Heartbeat Control safe to use?

It is a settings wrapper around the same filters shown above. The risk is not the plugin; it is disabling heartbeat on a screen that needs it, which is why the per-screen settings deserve more attention than the global switch.

A WP Life
A WP Life

Hi! We are A WP Life, we develop best WordPress themes and plugins for blog and websites.