Caching Page + Access Session via ajax

In the docs, it states that once there’s a session/cookie or anything like post/get request, that caching is disabled automatically by Kirby.

i want to still be able to benefit by the caching (loading)

and get/set session data via ajax e.g. route, controller, which should dynamically replace content (e.g. response to innerHTML of something, so i wonder if that’s possible to do.

up until now, the page will be cached as long as i delay the session (not creating it until it’s really being used) and destroy the session once it’s not being used anymore.

Example scenarios

  • delaying the session of a cart until the first item has been added
  • destroying the session if the cart has been emptied
    (this would enable caching outside the sessions)

consider using a “partial cache” to wrap json responses. some introduction can be found here: Remember this - Caching in Kirby

there are various ways for replacing certain parts of a website some examples…
GitHub - patrick-steele-idem/morphdom: Fast and lightweight DOM diffing/patching (no virtual DOM needed) (old school but still working very well)
Morph — Alpine.js (alpine v3)