/** * Implements hook_views_post_render(). */ function {{ machine_name }}_views_post_render(ViewExecutable $view, &$output, CachePluginBase $cache) { // When using full pager, disable any time-based caching if there are fewer // than 10 results. if ($view->pager instanceof Drupal\views\Plugin\views\pager\Full && $cache instanceof Drupal\views\Plugin\views\cache\Time && count($view->result) < 10) { $cache->options['results_lifespan'] = 0; $cache->options['output_lifespan'] = 0; } }