Cache part of a page?

Just for completeness, this is my final result:

Config

c::set('cache', true);
c::set('cache.ignore', ['*']);

Controller

<?php
return function($site, $pages, $page) {
  $cache = cache::get($page->slug()); //My slugs are unique
  if( ! $cache ) {
    $cache = array(
      'foo' => 'bar',
    );
    cache::set($page->slug(), $cache);
  }
  return array(
    'cache' => $cache,
  );
};

Template/snippet

echo $cache['foo'];
1 Like