diff options
| author | winter | 2025-01-28 22:20:26 +0000 |
|---|---|---|
| committer | winter | 2025-01-28 22:20:26 +0000 |
| commit | 0c9c33d2f626c235ef24d9fabc723be11cd6088b (patch) | |
| tree | 6a3bf1d416f85272b8ed3c5b9d2c412534866e94 /routes | |
| parent | f7a6123c404b126fd550cbb29aec82c88613ce02 (diff) | |
put some cache-control on static/storage resources
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/static.php | 1 | ||||
| -rw-r--r-- | routes/storage.php | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/routes/static.php b/routes/static.php index 0944014..f28c7e4 100644 --- a/routes/static.php +++ b/routes/static.php @@ -11,6 +11,7 @@ Router::getInstance()->mount('/static/:path', function (array $args) { } $fileExtension = explode('.', basename($realPath)); $fileExtension = $fileExtension[count($fileExtension) - 1]; + header('Cache-Control: max-age=604800'); // 1 week header('Content-Type: ' . match ($fileExtension) { 'css' => 'text/css', 'js' => 'application/javascript', diff --git a/routes/storage.php b/routes/storage.php index 341770b..2ea0fc7 100644 --- a/routes/storage.php +++ b/routes/storage.php @@ -11,6 +11,7 @@ Router::getInstance()->mount('/storage/:oid', function (array $args) { if ($obj == null) { throw new NotFound('unknown object'); } + header('Cache-Control: max-age=604800'); // 1 week header("Content-Disposition: inline; filename*=UTF-8''" . urlencode($obj->filename)); $obj->passthrough(); }); @@ -23,5 +24,6 @@ Router::getInstance()->mount('/upload/:token', function (array $args) { if (!$storage->exists($token)) { throw new NotFound('unknown object'); } + header('Cache-Control: max-age=604800'); // 1 week $storage->passthrough($token); });
\ No newline at end of file |
