What is WordPress Heartbeat and How to Reduce admin-ajax.php Hits

WordPress is the most popular CMS in the world. They released the initial version of WordPress in 2003. It introduces new features every year. On August 1, 2013, WordPress Heartbeat was initially introduced in WordPress version 3.6. It allows your browser to communicate with the server when you are logged into the WordPress dashboard.

WordPress Heartbeat offers great functionality, it helps in post revision tracking, auto-saving of posts while composing, and user session management. WordPress Heartbeat sends a continuous pulse, as the name indicates, using AJAX calls to perform periodic tasks. In this article, we will explain what is WordPress Heartbeat and how to reduce admin-ajax.php hits.

What is WordPress Heartbeat

WordPress Heartbeat API is a tool that allows WordPress developers to make use of AJAX in a unique way. The pulse system will automatically tick or beat every 15-60 seconds and utilize the file admin-ajax.php on the website, for example, to check if someone who logged in to the dashboard is still active or not, to check if something has changed or not, etc.

The great functionality offered by WordPress Heartbeat is awesome. WordPress can keep track of what is going on in the website back-end and front-end. But, in some cases, this functionality can increase your server’s CPU usage and slow down your websites due to an excessive number of requests to admin-ajax.php.

At one point, you feel that your website is extremely slow, even after upgrading your hosting plan, optimizing the database, etc. Upon checking, you find out that there is an excessive number of requests to your admin-ajax.php file. Your hosting support would say that your WordPress website consumes a lot of CPU due to the high number of requests to admin-ajax.php.

While helpful, numerous admin-ajax.php requests can sometimes trigger high CPU usage. This will lead to performance issues and search engines do not like slow websites as well.

How to Reduce admin-ajax.php Hits

If you host your WordPress websites on a server with cPanel or DirectAdmin control panel, you can check the server report tools like AWStats, and you would see a lot of requests to your admin-ajax.php. The excessive number of requests would make your sites slow and could lead to account suspensions if they are hosted on shared hosting.

Completely disabling WordPress Heartbeat not only will break the connection between your web browser and server, but also you will lose great features like auto-saving posts and revisions, session management, etc. These are the disadvantages of completely disabling WordPress HeartBeat.

  • We would not be able to see realtime information about something if a plugin uses or relies on the WordPress HeartBeat to work properly. For example, the WordPress Site Health tools relis on WordPress Heartbeat. The tool will not return any results if we disable Heartbeat.
  • Automatic posts/revisions saving would not work, we would need to manually press the ‘Save Draft’ button to save our works.
  • Heartbeat APi also inlcudes post locking feature, with this feature only one person can open a post that currently being edited.

So, according to the disadvantages of fully disabling WordPress Heartbeat above, it is recommended to limit or reduce the WordPress Heartbeat instead. To limit or adjust the Heartbeat API frequency, we can use the Heartbeat Control plugin.

Install Heartbeat Control

To proceed with this step, make sure you have administrator access to your WordPress website. If yes, log in as an administrator to your WordPress dashboard then navigate to Plugins – Add New.

In the keyword field on the right, type heartbeat then you will see the search results. Choose the plugin as shown in the picture below.

what is wordpress heartbeat and reduce admin ajax php hits

Click on the Install Now button to proceed with the installation.

After completing the installation, do not forget to click on Activate Now button to activate it and start configuring it.

Configure Heartbeat Control

Now, we have successfully installed the plugin, and to modify the Heartbeat frequency you can go to Settings – Heartbeat Control.

reducing admin ajax php hits with wordpress heartbeat

In the General settings tab, you can change the setting to allow or disallow Heartbeat. But now, we are going to change the default Heartbeat frequency. To do this, you can click on the ‘Modify Heartbeat’ radio button and slide it to any values you like, in this article we will set them all to 300 seconds.

what is wordpress heartbeat and reducing admin ajax php hits


Finally, after modifying the heartbeat frequency, do not forget to click the Save Changes button.
By saving the new setting you will override the default Heartbeat frequency with the value you set on the Frequency slider options.

Please note, if you already have the WP-ROCKET plugin, you do not need to install this Heartbeat Control plugin because the WP-Rocket plugin has this functionality already.

That’s it. You have learned about WordPress heartbeat and how to reduce admin-ajax.php hits in this article.

If you are one of our web hosting customers and use our optimized WordPress Hosting, you don’t have to do all these by yourself, our expert Linux admins will set up and optimize your WordPress VPS for you, including but not limited to reducing the admin-ajax.php hits. They are available 24/7 and will take care of your request immediately.

PS. If you liked this post, on how to WordPress Heartbeat and how to reduce admin-ajax.php hits, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

4 thoughts on “What is WordPress Heartbeat and How to Reduce admin-ajax.php Hits”

  1. Hi! I have installed the Heartbeat Control plugin, but when I run speed tests for my site, it’s still showing up with an admin-ajax.php file taking over a second to load. Are there any other options?

    Reply
    • The Heartbeat Control plugin purpose is to manage the WordPress Heartbeat API call and to avoid your server from receiving continuous ajax requests made by the WordPress Heartbeat API that may result in overloading your server.

      Reply

Leave a Comment