Cache and scheduled posts

Hi all,

I currently have an issue that I’m not sure how to solve yet: Basically we schedule posts through defining a future date as the post date. So as soon as the post-date of a scheduled post is in the past, it’s supposed to show up in the blog. The problem is, the cache doesn’t get flushed when that happens, and the post doesn’t show up on the site without an additional refresh.

Did anyone run into this already and can point me into the right direction?


Kirby does not have a daemon process that is continuously running, so it can’t automatically flush the cache.

I think the best way would be to create a Kirby plugin that checks if any post has become visible since the last check. The plugin can then flush the cache. Plugins are always loaded, even if the cache is used, so they will always be able to check.

Okay thanks I’ll explore this route!

So how does kirby manage the cache when using static file caching?

What do you mean exactly?

Like there are a couple of cache busting methodologies for CSS and JS but how does kirby manage the cached files and how do they get outdated and refreshed? Like does kirby flush the cache ever or do you have to manage all by hand?

Kirby checks for the file modification date when trying to retrieve something from the cache. Items are flushed from the cache once they are older than the content.

Also, the cache is flushed whenever you create an new or update an existing page.

Thats what I wanted to know. :slight_smile: thanks for clarification

Just got into trouble with the cache and thought that I post it here instead of opening a new topic.

My question is how can I flush the cache manually? The docs say that I can use something like cache::flush()?
But my question is also where do I need to place that piece of code in order to get executed?

I am using a one-pager where every section of the page is a snippet. The news.php snippet is responsible for displaying Facebook events. The fetching of those events happens in a plugin called “FacebookEvents” (via api) and it then stores it locally in content/1-news/. When the event is expired it flushes the content/1-news/ folder and requests the next event, storing it again.
Now when I have caching activated this is not working anymore. The code for checking Facebook for new events will not be executed and the content (old event) will get served from cache until some action that makes the internal Kirby flush the cache gets executed.

This is how the snippet news.php looks like:

    // get the $page object 
    $news = $pages->findByURI('news');

    $fbe = FacebookEvents($news);
    // if the event expired getNews will return the next event, else the locally stored
    $fb_event = $fbe->getNews('12345');

How can I flush the cache in a plugin? What code will get executed if caching is activated? Do I need a controller or something for the “home” template?

Yes, you can cache the flush from the plugin. The code in the plugin will always be executed, even with cache enabled.

You plugin could check if there is a new event (as compared to what is in the cache) and if yes, it could flush the cache.

Did you explore this? I have exactly the same setup and problem.