How To Optimize WordPress Heartbeat Without A Plugin
- To see if the user is still there.
- To see if something has changed.
Optimizing Heartbeat API
Today, I am going to show you code that can be added to your functions.php file and it will reduce the "tick" of the default heartbeat from 15 seconds to 60 seconds. This reduces the number of pings by 75%. Add the following piece of code to your functions.php file. As stated above, this reduces the load on your server dramatically. This is especially true if your website's host limits your CPU cycles.function sert_heartbeat_settings( $settings ) {
$settings['interval'] = 120; //Anything between 15-120
return $settings;
}
add_filter( 'heartbeat_settings', 'sert_heartbeat_settings' );
Scott Hartley
Founder & CEO, Sert Media
Founder and CEO of Sert Media, a Nashville-based digital marketing agency. Scott has spent over 15 years helping businesses grow through SEO, web performance optimization, and strategic digital marketing. His deep expertise in WordPress development, site speed, and technical SEO has guided hundreds of brands toward measurable results. When he's not auditing Core Web Vitals or refining campaign strategies, he's writing about the tools, techniques, and trends shaping the modern web.
Related Articles
How to Add Security Headers to WordPress Using Cloudflare Transform Rules
If you've ever run your WordPress site through securityheaders.com and gotten a D or F…
Use This Cloudflare Rule To Reduce Plugin Hack Attempts
Cloudflare Firewall Rules give you a lot of flexibility in further protecting your website. Here…
Set Up Cloudflare's Automatic Platform Optimization Feature
Automatic Platform Optimization (APO) is a new feature from Cloudflare that allows you to cache…