From: Mischa POSLAWSKY Date: Tue, 4 May 2021 17:01:33 +0000 (+0200) Subject: foto: api directory modification headers X-Git-Tag: v5.3~14 X-Git-Url: http://git.shiar.nl/minimedit.git/commitdiff_plain/0173ca693edf712e6f4c85a14a8b1befc9a50bf2 foto: api directory modification headers Report presence and date to reduce dashboard bandwidth, with minimal cache-control to avoid dynamic caching. --- diff --git a/foto/index.php b/foto/index.php index 1ebb539..45c49c9 100644 --- a/foto/index.php +++ b/foto/index.php @@ -11,6 +11,13 @@ $Page->title = ($nav ? implode(' ', $nav) . ': ' : '') . $title; if ($_SERVER['HTTP_ACCEPT'] === 'application/json') { header('Access-Control-Allow-Origin: *'); + header('Cache-Control: max-age=10'); + if (file_exists($rootdir)) { + header('Last-Modified: '.gmdate(DATE_RFC7231, filemtime($rootdir))); + } + else { + http_response_code(404); + } $imgs = []; foreach (glob("$rootdir/*.jpg") as $path) { $target = preg_replace('{^(\.\./)*}', '', readlink($path));