Want to reduce WordPress’ load on your server? Here’s how…Mar 4th, 2012 | By admin | Category: Internet
Alright, I’ve gone over wp-super-cache, i’ve gone over all sorts of things but today I learned a shocking little secret about wordpress. Every single time a user hits your blog wordpress runs wp-cron.php, brilliant isn’t it? Why the hell would wordpress run a file like WP-CRON for every visitor? Shouldn’t the name of the file alone give you some hint as to how it should be run? Oh I don’t know, maybe buy a fucking cronjob??!?!
GAH! Anyways, the solution is pretty simple. Go into your wp-includes/cron.php file and find this line:
if ( strpos($_SERVER[‘REQUEST_URI’], ‘/wp-cron.php’) !== false || ( defined(‘DISABLE_WP_CRON’) && DISABLE_WP_CRON ) )
Now, replace this line of code with the following:
if ( strpos($_SERVER[‘REQUEST_URI’], ‘/wp-cron.php’) === false || ( defined(‘DISABLE_WP_CRON’) && DISABLE_WP_CRON ) )
Done! Your cron no longer runs on a page load.. All you need to do is make a nice cronjob telling wordpress to run it’s automated/scheduled tasked on a reasonable schedule like every 2 hours or every 12 hours and you are set.