I am using transients for this scenarios. Result is saved to database (wp_options
table) with expiration set. It’s usable if the slow load time is below some reasonable treshold … one (first) visitor will have to wait that long to render his request, every other will see saved result.
$results = get_transient('my_results');
if( ! $results ) {
$results = my_intensive_calculations(); // etc...
set_transient( 'my_results' , $results, DAY_IN_SECONDS );
}
echo $results;
There is one disadvantage against crons – first visitor will have to wait to my_intensive_calculations()
response (cron request runs in background and don’t block page rendering). But its result will be cached and every other visitor will see page/template as fast as possible.