My WordPress site in cPanel is serving the admin-ajax.php
file which is wasting CPU resources. How can I solve this problem? Should I use this in my robots.txt file or not?
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
This file is often used front-end by themes and plugins. It was changed in WordPress robots.txt file a couple of years ago to allow crawling for this reason, after an issue with google being unable to crawl it.
The WP Core ticket thread can be found here and offers further information https://core.trac.wordpress.org/ticket/33156
If by “allow” you mean to allow Google to crawl it, yes. Google wants to see how your site is constructed including CSS, JS, and Ajax files.
/wp-admin/
URLs would be used for CSS, JS, or AJAX. The admin files are usually used by the website owner to write new content, approve contents, and such. It sounds like this URL might be an exception to that. If that is the case, it would probably be worth explaining that in your answer.
Commented
Mar 1, 2020 at 11:41
admin-ajax
? If that is only used by your site administrators, then you would disallow robot access to it. Even if you did that though, I don't see how it would help with CPU resources. Presumably it only does anything for a logged-in administrator.