]> git.joonet.de Git - adminer.git/commitdiff
Use file caching only in non-dev
authorJakub Vrana <jakub@vrana.cz>
Tue, 20 Feb 2018 21:08:52 +0000 (22:08 +0100)
committerJakub Vrana <jakub@vrana.cz>
Tue, 20 Feb 2018 21:08:52 +0000 (22:08 +0100)
adminer/file.inc.php
compile.php

index c2d53d98f0c70d4a03c0aa9698e45b40a2cdf7e6..8c817697a12ee1362c34a4d4f9e50ad9f4ea395a 100644 (file)
@@ -1,13 +1,5 @@
 <?php
-//! rewrite in compile.php to cache moderately with -dev version
-if ($_SERVER["HTTP_IF_MODIFIED_SINCE"]) {
-       header("HTTP/1.1 304 Not Modified");
-       exit;
-}
-
-header("Expires: " . gmdate("D, d M Y H:i:s", time() + 365*24*60*60) . " GMT");
-header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
-header("Cache-Control: immutable");
+// caching headers added in compile.php
 
 if ($_GET["file"] == "favicon.ico") {
        header("Content-Type: image/x-icon");
index 9390540dd955ddb595e4019fe373798f6ec90514..0f00b779bccee65815ab12dc1643fbdafce884ee 100755 (executable)
@@ -36,11 +36,26 @@ function lang_ids($match) {
 }
 
 function put_file($match) {
-       global $project;
+       global $project, $VERSION;
        if (basename($match[2]) == '$LANG.inc.php') {
                return $match[0]; // processed later
        }
        $return = file_get_contents(dirname(__FILE__) . "/$project/$match[2]");
+       if (basename($match[2]) == "file.inc.php") {
+               $return = str_replace("\n// caching headers added in compile.php", (preg_match('~-dev$~', $VERSION) ? '' : '
+if ($_SERVER["HTTP_IF_MODIFIED_SINCE"]) {
+       header("HTTP/1.1 304 Not Modified");
+       exit;
+}
+
+header("Expires: " . gmdate("D, d M Y H:i:s", time() + 365*24*60*60) . " GMT");
+header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+header("Cache-Control: immutable");
+'), $return, $count);
+               if (!$count) {
+                       echo "adminer/file.inc.php: Caching headers placeholder not found\n";
+               }
+       }
        if (basename($match[2]) != "lang.inc.php" || !$_SESSION["lang"]) {
                if (basename($match[2]) == "lang.inc.php") {
                        $return = str_replace('function lang($idf, $number = null) {', 'function lang($idf, $number = null) {