Last-Modified and If-Modified-Since in http header

Hi all!

How to correctly add Last-Modified and If-Modified-Since to the http header based on the date the page was modified?

Thanks!

This should work, e.g. in a controller:

$kirby
    ->response()
    ->header('x-foo', 'bar');

Thanks!

In site/controllers/site.php

return function ($kirby,  $page) {
    $kirby->response()->header('Last-Modified', gmdate("D, d M Y H:i:s \G\M\T", $page->modified()));
};
1 Like