简体   繁体   中英

Decreasing number of admin-ajax requests - WordPress

I have a client that have to optimize for SEO and pagespeed. The website is WordPress using classified ads theme - AdForest. Which the problems are coming from. I have tried anything from turning off all plugins to plugins etc., none worked, he does not want to pay for support extension. So I have a problem. The theme is doing HIGH CPU overload and we changed from hosting to VPS, which did not solved the problem.

I see that if someone is on the main page, just load it and do nothing, leave it opened for hour and a half it will load more than 5 000 requests from admin-ajax most of them are coming from custm.js file in the theme, the lines that I sow in Chrome console are usually important, but I think endless loading of requests is not right.

It's doing it every second. Imagine what happens if there are 15 users at one time.... And this is the most expensive VPS package with 8 GHZ processor many CPU time 8 Gb RAM etc.

Anyway. I WANT to reduce the requests for example: 100 requests per hour per user or something like that. Is there any way to do it?

you can simply limit the execution frequency. You can do this by using a plugin called Heartbeat Control.

Once the plugin is installed then go to Settings -> Heartbeat Control Settings and from the Heartbeat Behavior drop-down choose Modify Heartbeat. If you are using the WP Rocket caching plugin then it's possible to control heartbeat from the WP Rocket settings .

Alternatively, you can choose the option Disable Heartbeat. This should completely disable this functionality and it will no longer add to the executions number and CPU time used on your server. Please note disabling heartbeat can in some cases stop some plugin functionality from working.

To disable heartbeat edit the functions.php file of your child theme and paste the snippet below right after the opening

add_action( 'init', 'stop_heartbeat', 1 );
function stop_heartbeat() {
wp_deregister_script('heartbeat');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM