High Usage of admin-ajax.php in WordPress: Diagnosis & Resolution

Trying to create the best WordPress website? Then you might have come across the file admin-ajax.php. This unassuming script plays a huge role behind the scenes; it allows features like AJAX-powered forms, real-time notifications, etc. to function seamlessly without requiring constant page reloads.

However, high usage of admin-ajax.php in WordPress website can significantly impact your site’s performance, leading to slow loading times and even crashes. That’s a massive headache when you are trying to ensure the best user experience.

Well, through this blog, I’ll try to explain how the expert WordPress developers diagnose the high usage of admin-ajax.php and fix it effectively. Let’s begin.

What is admin-ajax.php?

admin-ajax.php is a core WordPress file that acts as a central hub for handling AJAX requests on your website. Think of it as a messenger that allows your website to communicate with the server in the background without needing to refresh the entire page.

Here’s what it does:

  • Enables Asynchronous Communication: AJAX (Asynchronous JavaScript and XML) allows your website to send and receive data from the server without reloading the page. This leads to a smoother and more interactive user experience.   
  • Handles Various Tasks: admin-ajax.php is responsible for processing a wide range of AJAX requests, such as:
    • Submitting forms   
    • Loading comments   
    • Updating content dynamically   
    • Implementing infinite scroll
    • Displaying real-time notifications
  • Acts as an intermediary: When a plugin or theme needs to perform an action in the background, it sends an AJAX request to admin-ajax.php. It then processes the request and sends back the necessary data.

Essentially, admin-ajax.php is a crucial component for many dynamic features on your WordPress site.

Impact of High Usage of admin-ajax.php on the WordPress Website

While admin-ajax.php is essential for dynamic WordPress functionality, excessive usage can lead to performance bottlenecks. That means poor speed and bad user experience. Here’s how:

  • Increased Server Load: Every AJAX request handled by admin-ajax.php consumes server resources like CPU and memory. A high volume of requests can overload your server, leading to slow response times and even website crashes.   
  • Slow Page Loading: When admin-ajax.php is bombarded with requests, it can significantly increase page loading times. This frustrates visitors and can negatively impact your search engine rankings.
  • Website Instability: In extreme cases, excessive admin-ajax.php usage can lead to website instability, causing errors like the dreaded “500 Internal Server Error” or timeout issues.
  • Poor User Experience: Sluggish websites with unresponsive features due to admin-ajax.php overload create a frustrating user experience. This can lead to higher bounce rates and lost conversions.
  • Plugin Conflicts: Sometimes, poorly coded plugins or theme functions can trigger unnecessary AJAX requests, further exacerbating the problem and making it difficult to pinpoint the source of the issue.
  • Security Vulnerabilities: Although rare, excessive and unoptimized AJAX requests can potentially expose your website to security vulnerabilities if not handled carefully.

In essence, high-usage of admin-ajax.php can turn your dynamic WordPress website into a slow, unstable, and frustrating experience. So you need to monitor the usage of this file carefully and optimize it regularly. 

How to Diagnose the High Usage of admin-ajax.php on the WordPress Website?

Diagnosing the root cause of high admin-ajax.php usage requires a little exploration. But with the right tools, you can pinpoint the issue quite clearly.

GTmetrix

This website performance analysis tool can help pinpoint whether admin-ajax.php is causing slowdowns on your WordPress site. Here’s the process for the same.

Step 1: Log into the GTmetrix website.

Step 2: On the homepage, enter your website’s URL in the field and click the “Test your site”.

gtmetrix

That will run a comprehensive performance check on the site. The process time will depend on the size of your website.

Step 3: After the check is run, you’ll see a Waterfall tab on the “Latest Performance Report” page.

Step 4: In the report page, search for admin-ajax.php through the search page. Here you will see a range of elements and their impact on the load speed. Here’s an example. The POST admin-ajax.php is taking more time to load than other requests.

post admin ajax php

Step 5: Click the POST admin-ajax.php and under the “Post” tab, you’ll see the details.

With respect to the above example, you’ll see that the count_hit script is causing the performance issue.

count hit script

Chrome Developer Console

Another simple, yet excellent tool for diagnosing the admin-ajax.php usage on your website is the Chrome Developer Console. Here’s how you go about the process.

Step 1: VIsit your website, or the page you want to analyze.

Step 2: Right-click on the page and click “Inspect”. That will open a console on the right-hand side.

Step 3: On the screen, go to the “Network” section and reload the page or site.

Step 4: You’ll see a filter box at the top. In that, type in “admin ajax” and you’ll see if any process is using a WordPress AJAX call.

Based on the results, you can go about fixing the issues. For that, you can follow the process shown in the next section or consult with our professional WordPress developers. We will help ensure the best results.

Having performance issues on your WordPress website?

How to Reduce the High Usage of admin-ajax.php in WordPress?

The resolution of the admin-ajax.php high usage issue depends on the culprit identified via the diagnosis. To that end, we’ll cover three resolution methods that may end up fixing the performance issues.

Disable the Plugins

Were you able to pinpoint the exact WordPress plugin generating excessive admin-ajax.php requests? In that case you can deactivate that one individually.

If you weren’t able to find the culprit, deactivate all plugins via the “Bulk Actions” option. Then you can start reactivating them one-by-one and check the logs each time. That will help you identify the exact plugin causing the issue. Then you can either contact the plugin developer for support or find an alternative.

Some plugins also offer settings to reduce AJAX requests. See if you can minimize the unnecessary requests.

Enable Website Caching

Next way to reduce the high usage of admin-ajax.php is caching. It significantly reduces server load by storing static versions of your website’s pages. This minimizes the need for repeated database queries and admin-ajax.php requests.

To enable the browser caching on your WordPress, install a plugin like WP Super Cache or W3 Total Cache. These plugins offer various caching mechanisms to optimize your website’s performance.

With the plugin, test the page cache, database cache, object cache, and browser cache, and enable the image optimization by selecting the “Lazy Load Images” button.

Or you can use the cPanel offered by your WordPress hosting provider and navigate the Cache Manager (or something similar) to manage the caching options.

Control WordPress Heartbeat API

WordPress Heartbeat enables real-time communication between the browser and the server. However, it can contribute to high admin-ajax.php usage. To control the usage, you can install a plugin like Heartbeat Control or LiteSpeed Cache plugin. But according to our WordPress experts, the latter would be better.

Here’s how you limit the Heartbeat API usage on your WordPress website using this plugin.

Step 1: Log into your WordPress admin dashboard.

Step 2: Install and activate the LiteSpeed Cache plugin.

Step 3: Navigate to the sidebar menu and go to LiteSpeed Cache → Toolbox → Heartbeat. You’ll see the Heartbeat Control option will be disabled by default.

Step 4: Turn on the option and modify the “Backend Heartbeat TTL” value according to your preference.

Step 5: Save the changes.

Manual Method

If you don’t want to install another plugin, you can also opt for the manual method. That entails editing the functions.php file of your WordPress website. Here’s how it goes.

Step 1: On the WordPress dashboard, go to Tools and open the Theme File Editor.

Step 2: Within the theme files, look for the function.php file and open it.

Step 3: Now, copy and paste the following code snippet to disable or limit the Heartbeat API.

add_action( 'init', 'disable_heartbeat', 1 );

function disable_heartbeat() {

wp_deregister_script('heartbeat');

}

Step 4: Save the changes by clicking “Update File”.If you still encounter the high usage of admin-ajax.php on your WordPress website causing significant performance drops, opt for our professional WordPress development services.

Want assistance with your WordPress project?

FAQs on High Usage of admin-ajax.php in WordPress

How do I know if high admin-ajax.php usage is affecting my website?
Signs include slow loading times, website crashes, high server load, and poor user experience. Tools like GTmetrix and your browser's developer tools can help diagnose the issue.
Can I completely disable admin-ajax.php?
No, disabling admin-ajax.php would break many dynamic functionalities on your WordPress website. The goal is to optimize its usage, not eliminate it entirely.
Can my theme affect admin-ajax.php usage?
Yes, poorly coded themes or themes with excessive AJAX requests can contribute to the issue. Consider switching to a more optimized theme.

To Summarize

Optimizing the admin-ajax.php file is significant for ensuring the well-performing WordPress website. This critical file handles the AJAX requests and can become a performance bottleneck if not properly managed. Excessive requests to admin-ajax.php can lead to increased server load, slow page loading times, and ultimately, a degraded user experience.

So you need to use tools like GTmetrix and Chrome Developer Console to identify the culprit and execute the resolution approach accordingly. You can take care of this issue by disabling or replacing the culprit plugin, enabling caching mechanisms, and controlling the Heartbeat API.

If you need help with any of these approaches, hire our WordPress professionals today!

author
Chinmay Pandya is an accomplished tech enthusiast specializing in PHP, WordPress, and Laravel. With a solid background in web development, he brings expertise in crafting innovative solutions and optimizing performance for various projects.

Leave a comment