Snippets and cache

I am having a problem with caching. I have closed pages for unauthorized users. These pages are cached. And it turns out that as soon as they get into the cache, they become available to everyone.

I would like to keep caching for closed pages, as they are quite “heavy”. Checking occurs in snippet init.php. Is it possible to disable caching in a snippet? :thinking:


<?php snippet('init') ?>
<?php snippet('header') ?>

... content

<?php snippet('footer') ?>

and init.php

    go('login', 302); 

Is it really a good idea to cache content that actually resides behind a login? You will somehow have to protect your cache because it will otherwise leak private content.

Regarding your logic inside init.php: wouldn’t it be possible to move that logic to a catch-all route?

Rather than using the page cache for such protected pages, I’d use a custom cache for the content that either gets the content from the cache if it exists or renders the page normally, if not, only for logged in users.