epl_listing_query_cache_stale_limit: how long old search results show while the cache rebuilds
Description #
After a listing changes, visitors keep getting the saved search results while WP-Cron rebuilds them in the background. This filter sets how long, in seconds, those old results may still be shown if the rebuild hasn't finished. After that, the next page load stops using them and runs each query again as visitors need it. The default is 10 minutes. See How the listing search cache works.
Usage #
add_filter( 'epl_listing_query_cache_stale_limit', 'my_function' );
Parameters #
$limit (int)
Seconds, counted from the first listing change since the last rebuild. Default 10 * MINUTE_IN_SECONDS (600).
Examples #
On a site where WP-Cron doesn't run often (for example DISABLE_WP_CRON with a server cron job every 15 minutes), show a new suburb in the search sooner:
function my_epl_search_cache_stale_limit( $limit ) {
return 2 * MINUTE_IN_SECONDS;
}
add_filter( 'epl_listing_query_cache_stale_limit', 'my_epl_search_cache_stale_limit' );
The limit is checked once per page load, the first time a cached listing query runs. A shorter limit means fresher results when WP-Cron is slow, and more queries run during page loads. See Hosting Cron Commands to run WP-Cron from a server cron job.
Source #
lib/includes/functions.php, in epl_listing_query_cache(). Since 3.6.