WordPress.org

Plugin Directory

wp-cache

#1569 closed defect (fixed)

WP Super Cache causes high "doing_wp_cron" load

Reported by: tigertech Owned by: gallir
Priority: normal Severity: normal
Plugin: wp-cache Keywords: wp-super-cache cron
Cc:

Description

We've recently noticed that some of the busy WordPress sites we host are calling "POST /wp-cron.php?doing_wp_cron" several times a second. This causes high load.

I believe we've traced this to a change in WP Super Cache 1.0. If someone was using a version of WP Super Cache from before version 1.0, and they then updated to version 1.0 or 1.1 without resaving the garbage collection settings, WP Super Cache can think that the garbage collection interval is 0.

This happens because wp-cache-phase2.php contains this code in schedule_wp_gc() near the bottom:

wp_schedule_single_event( time() + $cache_time_interval, 'wp_cache_gc' );

That code relies on the global $cache_time_interval being set in the "wp-cache-config.php" file. But on sites that have been upgraded as I described, that variable isn't present. The code cited above treats $cache_time_interval as zero, making WP Super Cache constantly schedule the next garbage cleanup for the current time. The code fires again on the next HTTP request, and so on in an infinite loop.

The code could protect against this problem (and others) with the addition of something like this before $cache_time_interval is used:

if ( !isset( $cache_time_interval ) )
  $cache_time_interval = 3600;

3600 seems appropriate because that's the default it gets set to (based on $cache_max_time) anyway.

Change History (1)

comment:1 donncha20 months ago

  • Resolution set to fixed
  • Status changed from new to closed

In [592326]:

Make sure sites that upgrade to 1.0 don't schedule the GC too often, props tigertech, fixed #1569. http://wordpress.org/support/topic/wp-super-cache-causes-high-doing_wp_cron-load?replies=3

Note: See TracTickets for help on using tickets.