Add Cache-Control and Pragma headers for improved caching in routes

This commit is contained in:
2026-11-04 15:35:32 +07:00
parent eab5acde17
commit 471589cc57
2 changed files with 3 additions and 0 deletions
+2
View File
@@ -131,6 +131,8 @@ $router->group('', function(Router $router) use ($app, $session, $config) {
if (str_ends_with($filePath, '.js')) $mimeType = 'application/javascript';
if (str_ends_with($filePath, '.css')) $mimeType = 'text/css';
$app->response()->header('Content-Type', $mimeType.'; charset=utf-8');
$app->response()->header('Cache-Control', 'public, max-age=864000');
$app->response()->header('Pragma', 'cache');
if (function_exists('gzencode') && str_contains($_SERVER['HTTP_ACCEPT_ENCODING'] ?? '', 'gzip')) {
$app->response()->header('Content-Encoding', 'gzip');
echo gzencode(file_get_contents($filePath), 9);