The WordPress Heartbeat API  was introduced in WordPress 3.6 to allow WordPress to communicate between the web browser and the server.

It is a simple server polling API built into WordPress, to allow near-real-time frontend updates.

Making use of /wp-admin/admin-ajax.php to run AJAX calls from the web-browser, it was designed to help with extended functionalities such as improving auto-saving, revision tracking, login timeouts, session management, and notifications about a post being locked when there are multiple editors.

When the page loads, the client-side heartbeat code sets up an interval (called the “tick”) to run every 15-60 seconds.

When it runs, Heartbeat gathers data to send via a jQuery event, then sends this to the server and waits for a response.

On the server, an admin-ajax handler takes the passed data, prepares a response, filters the response, then returns the data in JSON format.

The client receives this data and fires a final jQuery event to indicate the data has been received.

 

But these came at a cost.

If you visit https://gtmetrix.com/ or https://www.webpagetest.org/ or even use the Network tab via Chrome DevTools to view the complete list of requests especially the POST requests made by admin-ajax.php file.

You can also login to cPanel and use Awstats statistic tool.

The Awstats interface displays traffic statistics from the Advanced Web Statistics (AWStats) software, which compiles information about how users access your website.

To view AWStats traffic statistics for a domain, click View for the domain that you wish to view.

A new interface will appear that displays the AWStats traffic statistics for that domain.

Navigate to the “Page-URL (Top 25)” section to see the top 25 pages accessed on your site.

 

One thing that may notice is that admin-ajax.php requests being made seems to be dragging on forever.

This is especially true for WordPress website running the Woocommerce plugin or when using 3rd party plugins such as Visual Composer page builder plugin.

Not only does this cause serious backend high CPU usage that will drain your hosting resources and probably affect the overall stability of the server, but it also makes your WordPress website really slow.

This is bad since, with the first one, your web host may either push you to upgrade your account when a cheaper hosting package will suffice or terminate the account.

The second one will impact your website SEO ranking since Google uses page load speed as one of the indicators in their algorithm to rank sites.

 

There is a very effective way to correct this behavior to save money and give your website visitors a better experience.

You need a plugin called WordPress Heartbeat Control created by a WordPress developer called Jeff Matson which allows you to manipulate the WordPress heartbeat.

It currently has 80,000+ active installs with a 4.5 out of 5-star rating.

This will not only save you time but a great amount of grief as well.

You can download it from the WordPress repository or by searching for it within your WordPress dashboard via Dashboard > Plugins > Add New.

Search the plugin by name, click install and activate it.

Upon activation, go to Settings > Heartbeat Control Settings and from the Heartbeat Behavior drop-down, choose Modify Heartbeat.

Then select all Locations.

By saving the settings you will override the default Heartbeat execution frequency with the value you set on the Frequency slider option.

 

We recommend disabling everywhere except for your post edit pages.

So proceed to add a rule that disables heartbeat on the “WordPress dashboard” and the “Frontend.”

You can also change the frequency from 15 seconds all the way up to 1800-3600 seconds.

By changing the interval to 1800-3600 seconds you are less likely to experience serious server performance issues.

 

If you are not using Woocommerce and yet experiencing slow-loading pages on your WordPress, start by disabling all the plugins on your WordPress site.

You can do this by logging via FTP, SSH or using cPanel File Manager, then right-click on the plugins folder and select Rename.

Change the name of the plugins folder to anything that you like for example, “plugins.deactivate”.

Once you do this, all of your plugins will be deactivated.

Then run a speed test on your site.

If you are unable to see admin-ajax.php, re-enable each plugin one by one while you run the test at each turn.

Once you find the plugin that is causing the admin-ajax.php issue, either reach out to the developer and ask him or her how you can get that resolved, or remove the plugin and find an alternative out there that does the same thing, but better.

Another plugin that Woocommerce users might find useful is WC Speed Drain Repair.

The plugin stops the loading of the extra items you do not need inside WooCommerce and speeds up WordPress core admin-ajax.php file.

 

Was this answer helpful? 0 Users Found This Useful (0 Votes)