This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

WordPress 5.0 is out. Test all the great new features before upgrading your Live website. Read How!

How to Reduce Admin Ajax Server Load in WordPress

Updated on  8th August

7 Min Read
reduce admin ajax
Reading Time: 7 minutes

When we talk about enhanced user experience on the web we immediately think of speed at which our web page loads for a visitor. A visitor tends to abandon the website if it takes more time to load than usual and seldom returns due to the bad experience they had with your website.

This is a serious issue as businesses invest both time and money in creating services, products, and content for their website and all of this is wasted due to low and unconverted traffic.

Since WordPress is the most widely used CMS, there are tons of different themes and plugins that often cause issues that are difficult to troubleshoot. WordPress website users eventually audit their website speed performance and observe a common warning about admin-ajax.php server response time delay. For an optimized user experience, experts recommend that the websites should load within 3 seconds to grab visitors attention.

Whether or not you have expertise in SEO, you must take into account the server response time of WordPress website to improve the user experience.

While testing the speed of your WordPress using online speed testing tools, you might have observed that WordPress admin-ajax.php is responsible for the slow loading experience. In this article, I will talk about this file and how you can reduce server response time and the CPU usage by decreasing the number of requests generated by admin-ajax.php.

What is admin-ajax.php in WordPress?

Back in 2013, WordPress introduced WordPress Heartbeat API that provided several important functionalities such as the autosave feature, login-expiration and post lock warning while another user is writing or editing a WordPress post.

Two very prominent features of the Heartbeat API are:

1. Autosave

Whenever you save a draft of a post and continue working on it, WordPress automatically saves the additions to the post. There is a clear difference between the autosave and manually saving the draft. Check out the following screenshot that shows both types of saves:

WordPress Post Autosave

2. Post Lock

Whenever you try to edit a post that another user is already working on, a pop-up warning about the situation will appear. There are three actions open to you.

WordPress Post Lock

The above-mentioned features are made possible because of the WordPress Heartbeat API that creates connections between the server and the browser for appropriate communication and responses.

WordPress Heartbeat API generates requests for communication with the server and triggers events on receiving data/response. This usually increases the load on the server and eventually slows down the WordPress Admin Dashboard.

A Live Example

I am logged into my WordPress dashboard and have started drafting a post. Next, I will leave the tab open for several minutes, and starts browsing in other tabs. The dashboard is still logged in, and you can see that admin-ajax is continuously sending requests.

admin-ajax Sending and Receiving Requests

According to the ticket mentioned above, admin-ajax.php in WordPress generates requests after every 15 seconds. The request can be any communication with the server.

How Plugins Overload the admin-ajax.php File

Majority of the times when we see the problems in an admin-ajax.php file is due to the requests made by installed plugins. These plugins make WordPress backend slow by sending requests to attain a certain functionality such as firing up a pop-up or updating a social sharing counter. These plugins make tons of these requests to stay functional.

However, making these requests does not necessarily mean that spiking up the admin-ajax.php file. If the requests are handled properly and plugin developers follow the best practices in utilizing the AJAX calls in their plugins then it does not have a negative impact on admin-ajax.php file. Therefore, it is also important to diagnose any plugin before deactivating it.

Plugin Diagnosis

It is important to diagnose the plugin properly in order to identify its impact on admin-ajax.php file which possibly can make WordPress backend slow. To do so, we will be using two tools GTmetrix and WebPageTest.

Test your site using any of the tools above. In case of GTmetrix, navigate to its Waterfall tab for complete list of requests. Upon looking at the list closely, you can see the POST requests made by admin-ajax.php file.

gtmetrix admi-ajax file

In our case, these requests were mainly made by a social sharing plugin. This particular plugin sends an ajax request to a social media accounts via API every 15 seconds to fetch updated sharing count. Expand the tab for detailed information. In the response tab, the exact spot can be seen which triggers these requests.

Chrome comes with developer tools which can help you in analyzing the requests made by various plugins. To do so, open the website in chrome browser go to inspect element and click on Network tab.

developer tool network

Reload the page and see the list being populated with updated requests. In the filter box, type ajax or admin-ajax to filter the required files. This gives you insight into the number of requests as well as their frequency and the source of the request.

Next, click on the file to see further information. In the response tab, it gives you some hint of the plugin causing this request. In my case, this time, it was triggered by WP Popular plugin (WPP). A plugin which highlights the most popular post over a specific course of time.

developer tool network

To avoid this, make sure that the plugin you are using is updated and if not then try opening a support ticket so it’s developers can fix the issue. If possible, you may also replace it with another plugin, which is updated and does not overload admin-ajax.php file.

Running a thorough diagnosis is important before getting rid of any plugin as some plugins are critical for your WordPress site. The above tools can help you in reaching to the root cause and choosing the best possible solution to overcome it.

In the next section, we will see how can we reduce these requests and prevent the admin-ajax.php file from getting overloaded.

Speed up WordPress Admin Dashboard

To speed up the WordPress backend, the best approach is to disable the Heartbeat API or at least set a longer time interval so that it does not hit the server after every few seconds.

Install Heartbeat Control Plugin

Login to your WordPress Admin Dashboard, navigate to Plugins >> Add New, search for Heartbeat Control, Install and Activate it.

Configure Heartbeat Control Plugin

Navigate to Settings >> Heartbeat Control Settings. There you will find three drop-down menus for configuring the plugin.

Allow Heartbeat1. Allow Heartbeat:

You can select the areas where the Heartbeat API will work. There are three options to choose from:

Heartbeat Locations

  • WordPress Dashboard: This will enable the Heartbeat API for WordPress dashboard.
  • Frontend: This will enable API on the frontend.
  • Post Editor: Mark this checkbox, if you want to allow the Heartbeat API to be enabled on autosave and post lock features.

2. Disable Heartbeat:

Select this if you want WordPress Heartbeat API to disable on particular locations. Be careful while choosing the locations because other plugins might also be using the WordPress Heartbeat API. If you are the sole user of the WordPress backend, I would suggest disabling it everywhere and then check whether it breaks the website. However, if your site has more than one user who contributes regularly, I would propose that you allow the Heartbeat API only on the post edit pages.

Heartbeat Behavior3. Modify Heartbeat:

This drop-down allows you to set the time interval, ranging 0 – 300 seconds to execute admin-ajax requests. By setting it to 120 seconds, the request will be generated after every 120 seconds. That will drastically reduce the load on the server. Adjust it according to your needs.

Modify Heartbeat Frequency

Create Multiple Rules

You can create multiple rules based on your requirements. For example, you want WordPress Dashboard to trigger on 120 seconds but Post Editor to be triggered on 60 seconds. To do this, you need to create two rules. One for the WordPress Dashboard and other for Post Editor and set their frequency to 120 and 60 respectively.

Detect Plugins That Use the Heartbeat API

Now that you have set up everything, it is time to check which plugins are using the admin-ajax.php file and slowing down the website.

Go to GTmetrix, enter the URL of your site. It will take a few moments to analyze the site. Once done, navigate to the Waterfall tab and you will see how much time a file is taking to connect and response. Scroll down a bit, and see if there is an entry for POST admin-ajax.php. If yes, expand it and navigate to the Post tab. From here, you can identify the culprit plugin. In my case, the plugin “desktop switch” is using the admin-ajax.php file and is continuously sending requests to the server. This is the time to make a decision, either replace it with another plugin or cross your fingers.

POST admin-ajax.php

Final Words

Considering its feature set, the Heartbeat API is very useful on your WordPress website. However, if not used correctly, it can increase the load time of a WordPress backend and the front end by sending to and fro WordPress admin-ajax requests.

There are only two solutions to this issue. Either, disable the Heartbeat API/enable it in a few locations only, or upgrade to a managed WordPress cloud hosting that could handle the load of the requests and also reduce server response time.

If you are using any caching plugin, such as W3TC, don’t forget to disable the object cache. This will also speed up the WordPress dashboard.

If you have any suggestion or query, feel free to post a comment below. I would follow it up ASAP!

Share your opinion in the comment section. COMMENT NOW

Mustaasam Saleem

Mustaasam is the WordPress Community Manager at Cloudways - A Managed WordPress Hosting Platform, where he actively works and loves sharing his knowledge with the WordPress Community. When he is not working, you can find him playing squash with his friends, or defending in Football, and listening to music. You can email him at mustaasam.saleem@cloudways.com

Be the first to check out WordPress 5.0

Use our Staging feature before upgrading your website to WordPress 5.0.

Get Our Newsletter
Be the first to get the latest updates and tutorials.

THERE’S MORE TO READ.