diff options
author | Jonas Kohl | 2024-12-10 11:47:59 +0100 |
---|---|---|
committer | Jonas Kohl | 2024-12-10 11:47:59 +0100 |
commit | c81ecbf2192ffa5643b0e6d14c8e86610c3a1fb6 (patch) | |
tree | 16fef772715333fcc5c5facee2df0abc9fb5660c | |
parent | 6dd994935deb5cf988642d37348f6803a68683d4 (diff) |
Small tweak
-rw-r--r-- | src/application/actions/ctheme/get.php | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/application/actions/ctheme/get.php b/src/application/actions/ctheme/get.php index 79f6353..558f8d2 100644 --- a/src/application/actions/ctheme/get.php +++ b/src/application/actions/ctheme/get.php @@ -2,6 +2,7 @@ // options $enableLogging = true; +$useEtag = true; $etag_strip_gzip_suffix = true; $cssFatal = function(string $msg): never { @@ -25,7 +26,7 @@ header("Content-Type: text/css; charset=UTF-8"); header("Cache-Control: no-cache"); // Disable Apache's gzip filter, as it interferes with our ETag // (Apache adds '-gzip' as a ETag suffix) -if (!$etag_strip_gzip_suffix) +if ($useEtag && !$etag_strip_gzip_suffix) apache_setenv('no-gzip', '1'); $themeName = $_GET["theme"] ?? $_COOKIE["theme"] ?? env("MYSTIC_FORUM_THEME") ?? "default"; @@ -59,17 +60,22 @@ foreach ($theme->files as $file) { } else $cssError($buffer, "Could not include file $file"); } -$etag = md5($buffer); -$ifNoneMatch = $_SERVER["HTTP_IF_NONE_MATCH"] ?? null; -if ($ifNoneMatch !== null) { - $ifNoneMatch = trim($ifNoneMatch, '"'); - if ($etag_strip_gzip_suffix) - $ifNoneMatch = preg_replace('/-gzip$/', '', $ifNoneMatch); +$ifNoneMatch = null; +if ($useEtag) { + $etag = md5($buffer); + + $ifNoneMatch = $_SERVER["HTTP_IF_NONE_MATCH"] ?? null; + if ($ifNoneMatch !== null) { + $ifNoneMatch = trim($ifNoneMatch, '"'); + if ($etag_strip_gzip_suffix) + $ifNoneMatch = preg_replace('/-gzip$/', '', $ifNoneMatch); + } + + header("ETag: \"$etag\""); } -header("ETag: \"$etag\""); -if ($ifNoneMatch === $etag) +if ($useEtag && $ifNoneMatch === $etag) http_response_code(304); else echo $buffer; |