From 0173ca693edf712e6f4c85a14a8b1befc9a50bf2 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Tue, 4 May 2021 19:01:33 +0200 Subject: [PATCH] foto: api directory modification headers Report presence and date to reduce dashboard bandwidth, with minimal cache-control to avoid dynamic caching. --- foto/index.php | 7 +++++++ 1 file changed, 7 insertions(+) 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)); -- 2.30.0