get_minified_js: store and check tt-rss version in cached files
This commit is contained in:
parent
7eb87b80d5
commit
aa9f7d4447
|
@ -2287,19 +2287,26 @@
|
||||||
if (!isset($_GET['debug'])) {
|
if (!isset($_GET['debug'])) {
|
||||||
$cached_file = CACHE_DIR . "/js/".basename($js).".js";
|
$cached_file = CACHE_DIR . "/js/".basename($js).".js";
|
||||||
|
|
||||||
if (file_exists($cached_file) &&
|
if (file_exists($cached_file) && is_readable($cached_file) && filemtime($cached_file) >= filemtime("js/$js.js")) {
|
||||||
is_readable($cached_file) &&
|
|
||||||
filemtime($cached_file) >= filemtime("js/$js.js")) {
|
|
||||||
|
|
||||||
$rv .= file_get_contents($cached_file);
|
list($header, $contents) = explode("\n", file_get_contents($cached_file), 2);
|
||||||
|
|
||||||
} else {
|
if ($header && $contents) {
|
||||||
$minified = JShrink\Minifier::minify(file_get_contents("js/$js.js"));
|
list($htag, $hversion) = explode(":", $header);
|
||||||
file_put_contents($cached_file, $minified);
|
|
||||||
$rv .= $minified;
|
if ($htag == "tt-rss" && $hversion == VERSION) {
|
||||||
|
$rv .= $contents;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$minified = JShrink\Minifier::minify(file_get_contents("js/$js.js"));
|
||||||
|
file_put_contents($cached_file, "tt-rss:" . VERSION . "\n" . $minified);
|
||||||
|
$rv .= $minified;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$rv .= file_get_contents("js/$js.js");
|
$rv .= file_get_contents("js/$js.js"); // no cache in debug mode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue