Menu
whm logo
  • News
  • Websites
  • Business
  • Servers
  • Services
    • CPanel Hosting
    • EZ Website Builder
    • VPS Hosting
    • Dedicated Servers
    • Reseller Hosting
    • Domain Registrstion
whm logo
wordpress
January 26, 2017January 26, 2017

How to stop admin-ajax from overloading your WordPress site

Share it here
twitter facebook pinterest linkedin

The WordPress Heartbeat API is used to have WordPress to connect between your web browser and the WordPress script or server. It is also used for session management, revision tracking, and auto saving. The WordPress Heartbeat API uses the file  /wp-admin/admin-ajax.php.

The issue is this file can also cause excessive requests to admin-ajax.php, leading to high load and CPU usage. If a web browser is left open on a page using the Heartbeat API, this could potentially be a major issue.

The best solution is to remove it, or as a alternative you can change it only run every 60 seconds.

How to remove admin-ajax.php from WordPress

1. To remove the Heartbeat API, locate your WordPress theme’s functions.php file.

If you are using the default Twenty Fifteen theme, the path would look like:

/home/username/public_html/wp-content/themes/twentyfifteen/functions.php

Make a copy of the file, something like functions.php-bk just to be safe.

2. Now disable WordPress Heartbeat everywhere.

Towards the top of the functions.php file, add the highlighted code to disable the Heartbeat everywhere:

 * @since Twenty Fifteen
 */

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

function stop_heartbeat() {
        wp_deregister_script('heartbeat');
}

/**
 * Set up the content width value based on the theme's design.

Once it’s added save the file and make sure everything still works. This should take care of it and allow WordPress to work faster without the admin-ajax code.

 Change the frequency of the default Heartbeat requests

1. Make a backup copy of this file:

/home/username/public_html/wp-includes/js/heartbeat.min.js

2. Find the 3 separate instances for request activity, 15 seconds, 30 seconds, and 60 seconds, and change the time intervals to:

B.mainInterval<15?B.mainInterval=15:…case 15: change to B.mainInterval<120?B.mainInterval=120:…case 120:

case 30:…30,b=1>b||b>30?30: change to case 300:…300,b=1>b||b>300?300:

B.mainInterval>60&&(B.mainInterval=60))…case 60:…mainInterval:60 change to B.mainInterval>600&&(B.mainInterval=600))…case 600:…mainInterval:600

 

We suggest double checking the code so only the numbers change, at this time the code is exact but WordPress is known to change their code time to time.

This will slow down the requests and keep any load issues at bay.

 

Continue Reading

← What is the best way to build a website?
Removing / Disabling the monster load lover WP-CRON.PHP file in WordPress →

Leave a Reply Cancel reply

You must be logged in to post a comment.

Connect with us
twitter facebook instagram youtube pinterest linkedin

Click to view coupon lup

Recent Posts

  • How to make an awesome about us page

    How to make an awesome about us page

    December 5, 2022
  • Is AI taking over SEO?

    Is AI taking over SEO?

    November 10, 2022
  • Transferring domains can be easy

    Transferring domains can be easy

    October 26, 2022
  • 6 highly effective ways to market a small business online

    6 highly effective ways to market a small business online

    September 28, 2022
  • A successful marketer

    A successful marketer

    August 22, 2022
  1. albertdavid123 on MySQL 5.5 is officially dying this weekApril 3, 2019

    Good bye 5.5. And thanks for we explaining the password change steps.

  2. Web Host Pro on Proper computer postureDecember 1, 2015

    Thanks!

  3. frank on 85% of people use the internet to find local businessesAugust 8, 2015

    I always do!

  4. Danny Walton on Free word invoice templateJuly 4, 2014

    Nice download

  5. Ken on Using Google Public DNSFebruary 22, 2014

    Great article!

All Rights Reserved Web Host Pro 2022