Caching variations

i am collecting ideas how to handle caching.

most of the time the built in cache methods work fine, however when having sites with sessions, forms etc.pp i always need to disable the feature for each site (or use the wildcards)

c::set('cache.ignore', array(

while for some pages i still want to maintain caching on a partly basis, e.g. cache everything except the form…

 $data = null;
        $cacheFile = kirby()->roots()->cache().DS.md5($feature->uid()).'.txt';
        if(!f::exists($cacheFile) || ( f::exists($cacheFile) && (f::modified($cacheFile) < $feature->modified()))){
          $data = snippet($feature->template(), array('data' => $feature), true);
          f::write($cacheFile, $data);
          echo $data;
        } else {
          $data = f::read($cacheFile);
          echo $data;

while this option has to be integrated quite individually depending on the content…

would there be any kind of solution to just mark / tag some content where the content within that function has to be called live and not being cachable?

right now i am rather excluding the whole page most of the time…

Some CMS’s I’ve worked with have “block caching”. This means you can choose which chunks that can be cached, and what shouldn’t be. However, this adds quite a bit more complexity.

Another use case where the Kirby caching not works, is where you have different versions of a page where users are logged in (welcome messages, user-specific toolbars/functionality, …).

I tend to like how Kirby keeps this simple out of the box, and would like to keep it that way.

For more complex sites though, more granular caching options would be nice indeed. A plugin or something that can be added afterwards would be nice. But I have no clue about the impact, let alone if if it would be possible.

1 Like

i am aware that caching user specific content will be troublesome, that’s why i am combing either of both methods from above to either cache a chunk, or a whole site depeding on the available content (session, user specific, forms, etc.)

the second code snippet actually works similar to a block-caching, as each template snippet will be called and cached by itself and others can be excluded at will.

built in caching is super simple and works great but however per page it’s always all or nothing.

anyhow… the idea is, to speed up site loading and performance, which seems to be crucial for many diffrent reasons…

and i just feel like page contents get handled much faster when having caching than iterating into the same content over and over again… especially when working on a localhost where the machine is not as powerful as a remote host…