Cache any data until set expiration time

Installs: 108

Dependents: 0

Suggesters: 0

Stars: 2

Watchers: 0

Forks: 0

Open Issues: 1


1.1.1 2019-02-05 23:26 UTC


GitHub release License Kirby Version Kirby 3 Pluginkit

Cache any data until set expiration time.

Commercial Usage

This plugin is free but if you use it in a commercial project please consider to


  • unzip as folder site/plugins/kirby3-lapse or
  • git submodule add site/plugins/kirby3-lapse or
  • composer require bnomei/kirby3-lapse

Usage Examples

Example 1: get/set

$key = md($page->url()); // unique key
// to delay data creation until need use a callback. do not use a plain array or object.
$data = function () {
    return [1, 2, 3];
// Bnomei\Lapse::lapse() or just lapse()
$data = lapse($key, $data);

Example 2: with custom expiration time

// if ommited config settings apply
$expires = 5; // in minutes. 
$data = lapse($key, $data, $expires);

Example 3: without the variables

// compressed code
$data = lapse(md($page->url()), function () use ($kirby, $site, $page) {
    // create some data. could be array, could be object, anything really.
    return [
        'title' => $page->title()->value(),
        'url' => $page->url(),
}, 5);

Parameter: force

$force = true;
$data = lapse($key, $data, $expires, $force);

Tip 1: devalidate on page modification

$key = md5($page->id().$page->modified());
$data = lapse($key, $data);

Tip 2: flush cache



All settings need bnomei.lapse. as prefix.

expires default: 60*24 in minutes

This Plugin uses minutes not seconds since K3 Cache does that as well. So be carefull in that regard when migrating from Jens' plugin.

debugforce default: true force refresh if Kirbys global debug options is active

field-as-object default: false will call $field->value() and store string instead of serializied object.


This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.



It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.


based on V2 version of