PHP code example of bnomei / kirby-content-last-modified
1. Go to this page and download the library: Download bnomei/kirby-content-last-modified library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bnomei / kirby-content-last-modified example snippets
<?= site()->contentLastModified()->toDate('c')
// http://example.com/some-page?last-modified=1726822135
if (site()->contentLastModified()->toInt() > intval(get('last-modified'))) {
kirby()->cache('my-cache')->flush();
}
$lastModifiedTimestamp = site()->contentLastModified()->toInt();
/* @var $cache \Kirby\Cache\Cache */
$cache = kirby()->cache('your-cache-name');
/* @var $rawValue \Kirby\Cache\Value */
$rawValue = $cache->retrieve('some-cache-key');
if ($rawValue && $rawValue->created() < $lastModifiedTimestamp) {
$cache->remove('some-cache-key');
}
// or with the helper
site()->removeFromCacheIfCreatedIsAfterModified('your-cache-name', 'some-cache-key', $lastModifiedTimestamp);
// defaults to site()->contentLastModified()->toInt()
site()->removeFromCacheIfCreatedIsAfterModified('your-cache-name', 'some-cache-key');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.