Pages cache stays empty

When enabling the cache with true, the right folder site/cache/ is created automatically (so the permissions are right) but it stays empty.

also: debug: false

any idea, what could be wrong?

Kirby 3.5.7

One potential reason you could look into is this: Disable cache on active sessions only · Issue #3976 · getkirby/kirby · GitHub – this affects the page cache both in case you are logged in or any template/snippet/hook/plugin etc. that is called for the request creates or checks for a session.

Whether this is the reason in your case can be determined by looking for a cache-control: no-store response header for the page request (the HTML document), which is returned in this case.

1 Like

That’s a very good hint, thank you. After some tedious debugging, I came across a part of my code where I was checking for the user and if they are logged in on every page load.

Glad I could help :slight_smile:

In case it’s of use to you: here’s a hacky solution I came up with, since I needed caching restored despite wanting to check for user status in a snippet – this little plugin is a temporary workaround until the discussed changes might appear in core.

Kirby::plugin('my/plugin', [
  'siteMethods' => [
    /* returns true if logged-in user and their role is in $roles (can be string or array) */
    'userIs' => function ($roles) {
      // the cookie check can be removed once core issue #3976 is resolved
      if (!empty(Cookie::get(option('session.cookieName')))) {
        if (kirby()->user() && in_array(kirby()->user()->role()->id(), (array)$roles)) {
          return true;
      return false;

This way, I can check for site()->userIs('admin') instead of kirby()->user() && kirby()->user()->isAdmin() while not triggering that cache exclusion rule for anybody who never logged in.

The trick of hiding the real session check (which triggers the “no caching” rule) behind a preposed check for overall existence of a Kirby session cookie of course only works on sites that use Kirby’s sessions exclusively for login …and any plugin still using the “normal” way of checking for a session would foil this effort as well.