How to reduce the load of admin-ajax.php on the server in WordPress

Website performance is a critical issue for any webmaster. Performance issues can affect user experience and potentially have a negative impact on SEO rankings, as Google uses page load time in its ranking criteria.

When we think about website performance, we often talk about page load time. In WordPress, a common scenario when talking about load time issues is that it could be due to a spike in the file admin-ajax.php. In this article, you will learn how to handle plugin conflicts caused by spikes in the file. admin-ajax.php and reduce request callbacks to optimize the load time of your WordPress site.

What is the admin-ajax.php file in WordPress?

In 2013, WordPress was released along with the one at its core. The WordPress Heartbeat API was created as a communication protocol between the browser and the server, and uses admin-ajax.php to send a request to the server and trigger events (or callbacks) when it receives data. The main features of the Heartbeat API are:

When you are writing an article in WordPress, save it as a draft and then continue working on it, WordPress automatically saves any additions you make.

  • Post blocking and login notification

On a WordPress collaborative site, you will receive a popup whenever you try to write or edit a post that another user is currently working on. You will also receive a pop-up notification when your session expires, and you need to log back in to continue working on your post.

Problems caused by admin-ajax.php

overflow file admin-ajax.php it can cause problems with page load time, which is a serious issue. The golden rule of the internet is that your site should fully load in 3 seconds or less. If it takes longer, you are likely to give your visitors a bad experience.

A slow page can also negatively affect your SEO positioning; Remember that Google uses loading speed as one of the indicators in its algorithm for . Also, a slow page means that the search engine can crawl fewer pages using your , and that will further affect the indexing of your pages.

For some of us, the only time we deal with this API is when we use speed test tools, like GTmetrix, to find out why. admin-ajax.php is slowing down our websites.

See also  .at domain: buy and register your at domain today

The causes of the spikes can come from two different sources, either third-party plugins or the WordPress Heartbeat API request in the admin section. We will see it in more detail below.

How plugins can overflow the admin-ajax.php file

Third party plugins cause the most common issue when users see a spike in admin-ajax.php. If implemented correctly, it’s definitely a good thing, as developers often use it to add functionality to their plugins. For example, developers can use AJAX requests to create a wp_query custom to display dynamic content on a cached page.

But sometimes, when many plugins use these queries, they can cause an overflow; therefore, it can create a spike and slow down the entire website. So if you’re a developer, this is a resource to implement.

As a website owner, you may need to diagnose plugins before disabling them. This is important to find out if a particular plugin is causing the load time issue.

Diagnose plugins

When there are conflicting plugins they can cause a load time issue. The old school way to solve it is to disable all plugins to fix the problem and re-enable them one by one through a removal process. But definitely not the best solution.

Let’s better use a more suitable method to find out the root cause of the problem with the following scenario.

When activating various plugins, you notice that the website needs more time to load completely. Then you do a site diagnostic using GTmetrix, which is a powerful free speed test tool that allows us to see individual response data for each post.

Method A

Go to the page, enter your website URL and click Analyze. This will take a while to fully analyze your site.

When it’s done, you’ll receive a report on the status of your website, such as your performance score and page details. Go to the tab waterfall (Cascade) to inspect the elements of the site in more detail.

The Waterfall window will present all the elements of your site. Although the rest of the files look fine, you notice that POST admin-ajax.php it takes longer to charge.

click on POST admin-ajax.phpand you will see four different tabs available: headers, parameters, post Y Response. When diagnosing this type of problem, you should look in the tabs post Y Response.

See also  What is Apache? Complete description

For this site, we see a hint in the tab postsince that request has something to do with the script «count_hit«.

That clue is leading us to suspect a certain hit counter plugin that we have previously installed. So, to prove that theory, we disabled that plugin and ran a second test with GTmetrix for our site.

Turns out our suspicion was correct. By disabling that plugin, we managed to reduce our load time by 2 seconds.

Method B

You can also use the Chrome Developer Console to find the suspicious plugin.

Open your website and right click on the page and select To inspect. Alternatively, on the Chrome tab, select Watch -> developer -> developer tools.

Click on the tab Net (Network) and reload the site.

In the filter box (just below the red dot) enter admin-ajax.php. There you will see the culprit of said problem. After that, you can disable the plugin and check if the problem persists.

As a website owner, if you really need to use this plugin, make sure you use the latest version. If you already did that and the problem still persists, contact the plugin developer and mention the case.

If the developer still can’t solve the problem, you can always replace it with another plugin. The wonderful thing about WordPress is that there are so many similar plugins to choose from. Simply go to and select the most used and updated plugin that offers the same functionality.

Improve the speed of the backend of your WordPress site

Sometimes the WordPress Heartbeat API enabled on the backend of your site can also cause performance issues. As we noted earlier, this feature helps to automatically save your work, to prevent project loss when something unexpected happens, and to manage concurrent writing/editing properly.

For example, the feature will fire every time you write a post and keep the tab open. This can cause high CPU usage, as can be seen by the number of callbacks in the developer console below.

CPU usage is an important issue for those using a shared hosting plan. Some hosting providers may not tolerate high CPU usage and it can eventually lead to , although that is not the case with .

See also  Hosting Joomla Spain - Optimized Plans For Joomla

To resolve this issue, you can do two things, disable the Heartbeat API, or lengthen the intervals between checks. Since the first option is not practical, we will use the second. To change the interval, you need a plugin called .

Go to Control Panel -> plugins -> Add new. Search for the plugin by name, click Install and then in Activate.

After activation, go to Settings -> Heartbeat Control settings. Here, you can set different rules for different locations.

Since we want to minimize the frequency of callbacks in the Post Editor, you can go through it and set the number of requests above 15. In this case we’ll set it to 200.

Once done, click Save Changes.

conclusion

You have learned about the Heartbeat API and its by-product, the file admin-ajax.php. You have also learned about the problems that arise when plugins override the function and cause slowdowns. You also know that the Heartbeat API can create a problem with your host if it is not managed correctly.

Remember, always test GTmetrix when you feel like your site is getting slow. Go to the Waterfall tab, select POST admin-ajax.php and see how everything is. It’s best not to disable all plugins at once, as sometimes they might not be the culprit. But if they are, you can replace them or limit the use of the Heartbeat API.

Do you have any similar experience handling the file admin-ajax.php? Leave a comment below so the world can learn from your story too!

Gustavo is passionate about creating websites. He focuses on the application of SEO strategies at for Spain and Latin America, as well as the creation of high-level content. When he is not applying new WordPress tricks you can find him playing the guitar, traveling or taking an online course.

Loading Facebook Comments ...
Loading Disqus Comments ...