How to mix static and dynamic sections? seeking advice

hello, on my homepage i display 3 sections a,b,c. different for every logged in user.

section a and c each should display one random page from a pool of pages assigned to that section. randomly selecting a page not on every reload, but only once a week.

section b displays all pages assigned to section b.

right now i managed to get the whole homepage to render new content every week by using a cache file.

problem is that section b must not be cached, but pulled dynamically on every reload, to reflect changes i make to the content within the 7 day cache period the other sections have. it must stay fully dynamic.

i now want to try to create separate cache files for sections a and c, while b gets pulled from content folder.

but before i try that my question is, is there any other maybe easier way but cache files to randomly create section a and c only once a week for each user, while section b stays fully dynamic?

any idea appreciated.


my lapse plugin has something called “magic key” for the cache. it allows you to devalidate the cached values if the key changes.

so if you add the userid/section and something for the date to the key you should be able to match your usecases.

like this…

$data = lapse(
    [$sectionID, date('W')], // will create key from array of objects
    function () use ($site, $page, $sectionID) {
       // build your collection each different based on sectionID
        if ($sectionID == 'a') return [....];
        if ($sectionID == 'b') return [....];
        return [...]; // array of ids (not page objects)
$pagesForSection = new \Kirby\Cms\Pages($data);
1 Like

tnx! will look into that!