I am creating posts for my plugins to make it easier to find them using the forum search and not just the docs search.
This plugin will track the most recent timestamp whenever you use the Panel or Kirby PHP API to update content. Like changing a page title, renaming a file, creating a new page, removing a file,…
That single timestamp might be useful if you need to know when the last modification on your content happened. For example when clearing caches or similar actions.
Output the last modified timestamp
<?= site()->contentLastModified()->toDate('c') ?>
Flush a cache if the content was modified after a given timestamp
// http://example.com/some-page?last-modified=1726822135
if (site()->contentLastModified()->toInt() > intval(get('last-modified'))) {
kirby()->cache('my-cache')->flush();
}
NOTE: yes… site()->modified() will give you the same value but it will crawl ALL content files, which might not be the most performant thing to do depending on how much content you have.