If you have stumbled across this post then you are probably trying to diagnose what is causing your slow load times. And you have probably already narrowed it down to your admin-ajax.php file as the culprit. But why exactly is the admin-ajax.php file causing these heavy load times? Well, read my two suggestions below to try and diagnose the root cause of the problem on your WordPress site. Anyone that knows me or reads my blog knows that I am a little OCD when it comes to speed. I wrote this post for a friend, he knows who he is :)[alert-note]There are two big problems with admin-ajax.php. 1st is WordPress Core and 2nd is Developer’s Plugins[/alert-note]
What is the admin-ajax.php file?
Basically in WordPress 3.6 the WordPress Heartbeat API was introduced, which allows WordPress to communicate between the web-browser and the server. This improved upon session management, revision tracking, and auto saving.
WordPress Core using admin-ajax.php
The WordPress Heartbeat API uses /wp-admin/admin-ajax.php to run AJAX calls from the web-browser. While this is great and all it can also cause high CPU usage and crazy amounts of PHP calls. For example if you leave your dashboard open it will keep sending POST requests to this file on a regular interval.
To read more about this issue, I suggest reading this article on WordPress Heartbeat and heavy admin-ajax.php usage.
There is a great free plugin now in the WordPress repository called heartbeat control which can help you fix this problem. Follow the steps below to configure.
Install Heartbeat control.
Go to Settings and click into “Heartbeat Control.”
Under “Control heartbeat locations” you have a couple options:
- Use default
- Disable everywhere
- Disable on dashboard page
- Allow only on post edit pages (I use the “Allow only on post edit pages” myself)
You can disable it altogether but remember this controls auto-saving and if you are working on a multi-author blog with multiple sessions this is something to take into consideration. Also the heartbeat API is used by a variety of plugins and disabling it could cause them to stop functioning.
Then you can setting the heartbeat polling frequency. I set mine to 60 seconds.
That should hopefully take care of some of your problems. If you are still experiencing delays than I would take a look at the next issue below.
Developer’s Plugins using admin-ajax.php
This is problem I keep running into recently. It seems that a lot of 3rd party developers are now somehow using admin-ajax.php and requests are getting sent for queries within certain plugins. The other day I narrowed down some speed issues on my site and more than a 1 second delay (about 60% of my site’s delay) was being caused entirely by a 3rd party plugin polling admin-ajax.php. Follow the steps below on how you can try and track down which plugin might be causing this. There might be a more efficient way to find this, but so far I have always been able to narrow it down quickly this way without access to the server or installing anything.
First go over to GTmetrix and run a free test of your website.
Then click into the “Timeline” tab and scroll down. You will most likely have POSTs to admin-ajax.php. In my example below you can see I have 5 POSTS to admin-ajax.php and they are adding up to significant delays.
Now expand one of the POST requests and click into the “Post” tab to see additional details. What you care about is the “action” name. From this action name you can usually determine right away what plugin is causing the problem, as the action is usually named something similar to what the plugin is doing or is called. From my example I see it is the “get_shares_count” action. Oh and under “share_count_array” I see it mentions “buffer.” Well there is only one plugin on my site sends requests for share counts from buffer and that is my social media sharing plugin (monarch). So immediately I know what it is. You can then disable your plugin, clear your cache, re-run your test to confirm it. Most likely those admin-ajax.php requests will be gone. For me the fix turned out to be that I needed to enable “caching” on my social sharing plugin in the options.
I have used this method above many times on different sites to quicly narrow down the plugin causing heavy load issues with admin-ajax.php. You might have to reach out to the developer of your plugin to get a fix.
Additional Ways to Speed up WordPress
If you are looking for additional ways to speed up your WordPress site then I highly recommend you read a couple of my other posts:
- How to Disable and Limit WordPress Post Revisions
- How to Delete Old WordPress Revisions from your DB
- Why You Should Be Using Locally Hosted Gravatars
- Click to Load Comments with Disqus DCL WordPress Plugin
- Decrease Load Times with the Lazy Load for Videos Plugin
- Free WordPress Cache Enabler Plugin + WebP Support
The P3 Profiler plugin can also be very useful in determining what plugin might be causing a delay.
As always feel free to leave your comments below!
Get More Stuff Like This
Marketing, WordPress, Blogging Tips, SEO and Reviews, once a week.
Thank you for subscribing.
Something went wrong.