Add Cache-Control and Pragma headers for improved caching in routes
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user