foto: api directory modification headers
[minimedit.git] / foto / index.php
index 1ebb53986bc08c3046e94ca32a1b5b60d137ef64..45c49c90458fa05bd050b2ba38f707f8d8f01f08 100644 (file)
@@ -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));