Ajax is a JavaScript-based Web technology that helps you build dynamic and interactive Web sites. WordPress uses Ajax to support many of its core management area functions, such as auto-saving articles, user session management, and notifications.
by default, WordPress guides all Ajax calls throughadmin-ajax.php
files located in the site’s/wp-admin
directory. A large number of simultaneous Ajax requests in
can lead to highadmin-ajax.php
utilization, resulting in a significant slowdown in the speed of servers and websites. This is one of the most common problems faced by many unoptimized WordPress sites. Typically, it appears as a slow website or HTTP 5xx error (mainly 504 or 502 errors).
in this article, you will learn about WordPress’sadmin-ajax.php
file, how it works, its advantages and disadvantages, and how to diagnose and fix highadmin-ajax.php
usage problems. What is a
- admin-ajax.php file? How does
- diagnose admin-ajax.php high-frequency usage problems on WordPress what is the
admin-ajax.php file? The
admin-ajax.php
file contains all the code that routes the Ajax request on the WordPress. Its main purpose is to use Ajax to establish a connection between the client and the server. WordPress uses it to refresh page content without reloading, making it dynamic and interactive with the user. A basic overview of how
Admin Ajax works on WordPress
because the WordPress core already uses Ajax to support its various back-end functions, you can use the same functionality to use Ajax on WordPress. All you need to do is register an operation, point it to your site’sadmin-ajax.php
file, and define how you want it to return a value. You can set it to return HTML, JSON, or even XML. The admin-ajax.php file
in
WordPress appears for the first time in WordPress 2.1 according to the WordPress Trac,admin-ajax.php file. It is also known as Ajax Admin in the WordPress development community.
checks Ajax usage
the chart above shows only the number ofadmin-ajax.php
requests, not where they might come from. This is a good way to see when the peak occurs. You can use it in combination with other techniques mentioned in this article to narrow down the main cause.
checks the number of admin-ajax.php requests in Chrome DevTools
you can also use Chrome DevTools to see how many requests are sent toadmin-ajax.php
. You can also check the “Timings” tab under the “Network” section to see how long it takes to process these requests.
as for the exact reasons behind the high utilization rate ofadmin-ajax.php
, there are two main reasons: one is the front end, the other is the back end. We will discuss both below. How
diagnoses admin-ajax.php high-frequency usage problems on WordPress
third-party plug-ins are one of the most common reasons for high admin-ajax.php usage. Typically, this problem occurs at the front end of the site and often appears in speed test reports.
but plug-ins are not the only culprits here, because themes, WordPress cores, web servers, and DDoS attacks may also be the reasons for high Admin Ajax usage.
lets us explore them in more detail. How
identifies admin-ajax.php sources of plug-ins and themes
driver plug-ins in the
WordPress.org plug-in library
WordPress developers often use Ajax to create dynamic and interactive plug-ins and themes. Some popular examples include the addition of real-time search, product filters, unlimited scrolling, dynamic shopping carts, and chat boxes.
just because the plug-in uses Ajax doesn’t mean it slows down your site.
looks at the admin-ajax.php request
in the WebPageTest report. Usually, the Admin Ajax loads at the end of the page load. In addition, you can set the Ajax request to load asynchronously, so it has little impact on user-perceived page performance.admin-ajax.php
, as you saw in the WebPageTest report above,
, is loaded at the end of the request queue, but it still takes 780ms. A single request takes a lot of time.
GTmetrix reports that admin-ajax.php usage has soared
when developers do not implement Ajax correctly on WordPress, it can cause serious performance problems. The GTmetrix report above is a perfect example of this behavior.
you can also use GTmetrix to mine individual articles and response data. You can use this feature to identify the cause of the problem.
to do this, go to the Waterfall tab of the GTmetrix report, then locate and click the POST admin-ajax.php item. You will see three tabs for this request: title, post, and response. The Post and Response tabs of the
POST admin-ajax.php request Headers data
View request will provide you with tips to find out the reason behind the performance problem. For this site, you can see clues in the Response tab. The response data
of the
POST admin-ajax.php request you can see that part of the response is related to the input tag with id set to “fusion-form-nonce-656”.
Quick search this clue will take you to ThemeFusion’s website, the creator of the Avada theme. Therefore, you can conclude that the request comes from the topic, or any plug-in bundled with it.
in this case, you must first ensure that the Avada theme and all related plug-ins are fully updated. If this doesn’t solve the problem, you can try disabling the theme and see if it can solve the problem.
Unlike disabling plug-ins, disabling themes is not feasible in most cases. Therefore, try to optimize the theme to eliminate any bottlenecks. You can also contact the theme’s support team to see if they can come up with a better solution.
testing another slow site in GTmetrix resulted in problems similar to those found in the Visual Composer page builder and notification bar plug-in.
another POST admin-ajax.php request response data
POST admin-ajax.php request Post data
is thankful that if you can’t solve the plug-in problem, you like to have many alternative plug-ins to try. For example, when it comes to page builders, you can also try using Beaver Builder or Elementor. How does
determine the source of high admin-ajax.php usageadmin-ajax.php
sometimes the Post and Response data shown in speed test reports may not be so clear and direct. It is not easy to find sources of high
usage here. In this case, you can always do it the old-fashioned way.admin-ajax.php
disables all plug-ins on your site, clears your site’s cache (if any), and then runs the speed test again. If
still exists, then the most likely culprit is the theme. But if you can’t find it, you must activate each plug-in one by one and run the speed test each time. By eliminating the process, you will target the root cause of the problem. The second most common reason why
admin-ajax.php
uses admin-ajax.php to diagnose back-end server problems with high
usage is that WordPress Heartbeat API generates frequent Ajax calls, resulting in high CPU usage on the server. Typically, this is caused by many users logging in to the WordPress back-end dashboard. Therefore, you won’t see this in the speed test.admin-ajax.php
by default, Heartbeat API’s
polls files every 15 seconds to automatically save articles or pages. If you are using a shared managed server, there are not many server resources dedicated to your site. If you are editing a post or page and opening tabs for a long time, there may be a large number of Admin Ajax requests.
for example, when you write or edit an article, a single user can generate 240 requests in an hour!
frequently automatically saves admin-ajax.php requests there are many requests on the
backend, only one user. Now imagine a site with multiple editors logged in at the same time. Such sites can quickly increase Ajax requests, resulting in high CPU usage.
DARTDRones actually encountered this problem when it extended its WooCommerce website to show up on Shark Tank.admin-ajax.php
and their
received more than 4100 calls in one day, with only 2000 unique visitors. This is a weak request access ratio. Heavy use of admin-ajax.php
on
dartdrones.com We notice that / wp-admin references URL and correctly identifies the root cause. These requests are due to the fact that DARTDRones administrators and editors often update the website to look forward to the broadcast of the program.
WordPress partially fixed this Heartbeat API problem a long time ago. For example, you can reduce the frequency of requests generated by Heartbeat API on hosts with limited resources. It also pauses itself after the keyboard / mouse / touch is inactive for an hour.
uses Heartbeat Control Plugin to reduce Ajax request
you can easily solve this problem using WP Rocket’s Heartbeat Control plug-in. It allows you to disable or modify the frequency of Heartbeat API with just a few clicks. After the
Heartbeat Control plug-in
installs and activates the Heartbeat Control plug-in, you can manage the frequency of Heartbeat API on the WordPress dashboard, site front end, and article editor. General Settings dashboard
of the
Heartbeat Control plug-in if your server CPU resources are limited, I recommend that you Disable Heartbeat on both the WordPress dashboard and the front end. You can also modify the Heartbeat frequency of the article editor option and increase it to 30 seconds (or even 60 seconds). The higher the frequency, the more server resources are saved.
the exact settings you must use vary from site to site. If you are not sure what to use, you can consult your Web developer.
high trafficadmin-ajax.php
caused by DDoS attacks or spam robots flooding your website with DDoS attacks or spam robots can also lead to high
usage. However, such attacks do not necessarily target increased Admin Ajax requests. It’s just collateral damage.
if your site is attacked by DDoS, your first priority should be to put it after a powerful CDN/WAF, such as Cloudflare or Sucuri.
to learn more about how to protect your website from such malicious attacks, you can refer to our in-depth guide on how to prevent DDoS attacks.
Summaryadmin-ajax.php
WordPress uses Ajax in its Heartbeat API to implement many of its core functions. However, if used improperly, it may result in an increase in loading time. This is usually due to the
caused by high-frequency requests for files.admin-ajax.php
in this article, you learned about the various reasons for high
usage, how to diagnose the cause of this symptom, and how to fix it. In most cases, following this guide should allow your site to recover immediately and run smoothly.