Generate cache from panel

Is there any method I can build the cache of pages just by clicking a button?
I currently have a fairly static website with lots of blog posts, and a few of the pages takes a while to load (which caching is improving :heart_eyes:)
Every time I do a new blog post or a tiny edit on any page in the panel, the cache is purged and I have to manually go to all the pages to build their cache

I think there’s a method that empties the cache, but not one that populates it directly (or it’s not documented). Looking at and the Cheat Sheet I don’t think there’s something that fits your need.

I think it t would be possible to write a plugin that refreshes the cache of every page, with something along the lines of but without actually writing the generated HTML to a file. But that requires writing quite a bit of PHP and digging in Kirby’s classes and methods.

If you want the cache to build automatically after editing, this would have to happen after every edit, which would probably result in very long saving times. Another approach could be a Dashboard Widget, that loads a sitemap and makes a request to every single URL of your page. Your could let this happen automatically (when a logged-in user visits the dashboard) or by clicking a button.

I was thinking something with a widget like you said, as often I save often, so building cache on save would be bad.
But doing something like a “crawler”, that visits all the pages could be an option

Decided to create a quick plugin myself. Probably not the best practise, but it seems to work.

1 Like