From 6a6658fbf1f0dae26ffba859442aa5e0d1138e2d Mon Sep 17 00:00:00 2001 From: crythoughts <234468996+crythoughts@users.noreply.github.com> Date: Sun, 23 Aug 2026 11:04:36 +0300 Subject: [PATCH 1/3] Update Router.php --- chandler/MVC/Routing/Router.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/chandler/MVC/Routing/Router.php b/chandler/MVC/Routing/Router.php index a3195aa..28fafce 100644 --- a/chandler/MVC/Routing/Router.php +++ b/chandler/MVC/Routing/Router.php @@ -207,7 +207,7 @@ private function delegateRoute(Route $route, array $matches): string return $this->delegateController($route->namespace, $route->presenter, $route->action, $parameters); } - public function delegateStatic(string $namespace, string $path): string + public function delegateStatic(string $namespace, string $path, ?array $queryParams): string { $static = $static = $this->statics[$namespace]; if (!isset($static)) { @@ -225,9 +225,17 @@ public function delegateStatic(string $namespace, string $path): string } } + // This is needed for ES6 modules. They do not use "?mod=" parameter and may be irrelevant + + $isLighterCaching = system_extension_mime_type($file) === "text/javascript" && $queryParams["mod"] == null; + if ($isLighterCaching) { + header("Cache-Control: no-cache, max-age=3600"); + } else { + header("Cache-Control: public, must-understand, immutable, max-age=628000000"); + } + header("Content-Type: " . system_extension_mime_type($file) ?? "text/plain; charset=unknown-8bit"); header("Content-Size: " . filesize($file)); - header("Cache-Control: public, must-understand, immutable, max-age=628000000"); header("ETag: $hash"); readfile($file); @@ -334,7 +342,15 @@ public function execute(string $url, ?string $parentModule = null): ?string if (preg_match("%^\/assets\/packages\/static\/([A-z_\\-]++)\/(.++)$%", $this->url, $matches)) { [$j, $namespace, $file] = $matches; - return $this->delegateStatic($namespace, $file); + $queryString = parse_url(preg_replace("%/+%", "/", $url), PHP_URL_QUERY); + + try { + parse_str($queryString, $queryParams); + } catch(\Throwable $e) { + $queryParams = []; + } + + return $this->delegateStatic($namespace, $file, $queryParams); } $match = $this->getMatchingRoute($this->url); From 8e998d31de2a2921d306e58936afd70a5ceed839 Mon Sep 17 00:00:00 2001 From: crythoughts <234468996+crythoughts@users.noreply.github.com> Date: Sun, 23 Aug 2026 11:04:36 +0300 Subject: [PATCH 2/3] Update Router.php --- chandler/MVC/Routing/Router.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/chandler/MVC/Routing/Router.php b/chandler/MVC/Routing/Router.php index a3195aa..fee29a9 100644 --- a/chandler/MVC/Routing/Router.php +++ b/chandler/MVC/Routing/Router.php @@ -207,7 +207,7 @@ private function delegateRoute(Route $route, array $matches): string return $this->delegateController($route->namespace, $route->presenter, $route->action, $parameters); } - public function delegateStatic(string $namespace, string $path): string + public function delegateStatic(string $namespace, string $path, ?array $queryParams): string { $static = $static = $this->statics[$namespace]; if (!isset($static)) { @@ -225,9 +225,17 @@ public function delegateStatic(string $namespace, string $path): string } } + // This is needed for ES6 modules. They do not use "?mod=" parameter and may be irrelevant + + $isLighterCaching = system_extension_mime_type($file) === "text/javascript" && $queryParams && $queryParams["mod"] == null; + if ($isLighterCaching) { + header("Cache-Control: no-cache, max-age=3600"); + } else { + header("Cache-Control: public, must-understand, immutable, max-age=628000000"); + } + header("Content-Type: " . system_extension_mime_type($file) ?? "text/plain; charset=unknown-8bit"); header("Content-Size: " . filesize($file)); - header("Cache-Control: public, must-understand, immutable, max-age=628000000"); header("ETag: $hash"); readfile($file); @@ -334,7 +342,15 @@ public function execute(string $url, ?string $parentModule = null): ?string if (preg_match("%^\/assets\/packages\/static\/([A-z_\\-]++)\/(.++)$%", $this->url, $matches)) { [$j, $namespace, $file] = $matches; - return $this->delegateStatic($namespace, $file); + $queryString = parse_url(preg_replace("%/+%", "/", $url), PHP_URL_QUERY); + + try { + parse_str($queryString, $queryParams); + } catch(\Throwable $e) { + $queryParams = []; + } + + return $this->delegateStatic($namespace, $file, $queryParams); } $match = $this->getMatchingRoute($this->url); From ba8984f2bd0f3a202d1478ace7bfa59c3bf8614e Mon Sep 17 00:00:00 2001 From: crythoughts <234468996+crythoughts@users.noreply.github.com> Date: Sun, 23 Aug 2026 11:29:40 +0300 Subject: [PATCH 3/3] Update Router.php --- chandler/MVC/Routing/Router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chandler/MVC/Routing/Router.php b/chandler/MVC/Routing/Router.php index 5b76feb..186c0fd 100644 --- a/chandler/MVC/Routing/Router.php +++ b/chandler/MVC/Routing/Router.php @@ -227,7 +227,7 @@ public function delegateStatic(string $namespace, string $path, ?array $queryPar // This is needed for ES6 modules. They do not use "?mod=" parameter and may be irrelevant - $isLighterCaching = system_extension_mime_type($file) === "text/javascript" && $queryParams && $queryParams["mod"] == null; + $isLighterCaching = system_extension_mime_type($file) === "text/javascript" && $queryParams["mod"] == null; if ($isLighterCaching) { header("Cache-Control: no-cache, max-age=3600"); } else {