diff options
author | Jonas Kohl | 2024-11-08 11:54:01 +0100 |
---|---|---|
committer | Jonas Kohl | 2024-11-08 11:54:01 +0100 |
commit | 81bfeab4e0effa0407f0e87cff86009eab69e78f (patch) | |
tree | 9e58174464d9f9c4ceaa277cb8a9c4c835cc1d1e | |
parent | 7542a02170aa8e779fd3ed12d6b4332ff99f22a6 (diff) |
Add cachebuster to files
-rw-r--r-- | public/index.php | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/public/index.php b/public/index.php index 9de0c7d..a7f9674 100644 --- a/public/index.php +++ b/public/index.php @@ -31,6 +31,13 @@ function delTree($dir) { return rmdir($dir); } +function file_cachebuster(string $filename): string { + return htmlentities(urlencode(md5( + strval(filemtime($filename)) . + strval(filesize($filename)) + ))); +} + $defaultCode = <<<java public class Program { public static void main(String[] args) { @@ -157,11 +164,11 @@ $csrf = csrf_token(); <title>Java</title> <link rel="stylesheet" href="dist/codemirror.css"> <link rel="stylesheet" href="dist/eclipse.css"> - <link rel="stylesheet" href="site.css"> + <link rel="stylesheet" href="site.css?_=<?= file_cachebuster(__DIR__ . "/site.css") ?>"> <script src="dist/jquery-1.12.4.min.js"></script> <script src="dist/codemirror.js"></script> <script src="dist/clike.js"></script> - <script src="site.js"></script> + <script src="site.js?_=<?= file_cachebuster(__DIR__ . "/site.js") ?>"></script> </head> <body> <div id="loader" style="display: none;"> |