This is indeed helpful, however, if you leave your WordPress admin open for long periods (for example when you write or edit posts), the AJAX requests from the API can pile up and generate high CPU usage, leading to server performance issues and even hosting account suspensions.
With Heartbeat Control by WP Rocket, you can easily choose to limit or completely stop the activity of the WordPress Heartbeat API. You can also add rules for specific locations (e.g. dashboard, frontend or post editor).
How to install the Heartbeat Control plugin for WordPress:
Log in to your WordPress administration dashboard and using the left sidebar, navigate to Plugins > Add New.
Search for "Heartbeat Control", then install and activate the plugin from the list of results.
In the left sidebar, click Settings > Heartbeat Control Settings, to configure the plugin.
The Heartbeat Control plugin allows you to create one or more rules to modify how the WordPress Heartbeat API works. This includes the ability to fully disable the API. Bear in mind that the API is used for a variety of functions (for example, allowing only one author to edit a post at a time) alongside a range of under the hood features that will be disabled if you completely switch it off.
Rules are prioritized by the order they appear on the screen. Rules closer to the top of the screen have priority over those towards the end.
Under Rule 1, click the Heartbeat Behaviour dropdown menu and select whether you want to allow, disable or modify Heartbeat.
In this example, we’ll select Modify Heartbeat.
Under Locations, the checkboxes allow you to target the rule to specific areas of WordPress. The WordPress Dashboard, Frontend and Post Editor are available for selection, along with a Select/Deselect All button to toggle the selection of all locations.
Click and drag the Frequency slider to a value of your choosing (in seconds). Moving the slider all the way to the right will delay the Heartbeat for 5 minutes (i.e. 300 seconds). You may need to fine-tune the Frequency after the rule has been created to achieve a balance between performance and functionality.
Click Save Changes to complete the configuration or Add Another Rule to continue tweaking Heartbeat settings. The arrows at the bottom of the screen allow you to change the priority of rules in the list.
That's all you need to know in order to modify the behaviour of the WordPress Heartbeat API. Nevertheless, this is just one way you can minimize the resource usage on your server and improve your WordPress website's performance. Look through our extensive knowledgebase to find out many more tips on how to optimize your site.