summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2014-08-19 14:50:25 +0400
committerAndrew Dolgov <[email protected]>2014-08-19 14:50:25 +0400
commitaa9f7d444729c3136e0549518eebf0c4c108d818 (patch)
tree63027594a4bb02ac4c3316ce6867fb757d5847b3 /include
parent7eb87b80d533d0bdd538938b69064352a8587204 (diff)
get_minified_js: store and check tt-rss version in cached files
Diffstat (limited to 'include')
-rw-r--r--include/functions2.php25
1 files changed, 16 insertions, 9 deletions
diff --git a/include/functions2.php b/include/functions2.php
index 07024d38f..9d8bc76aa 100644
--- a/include/functions2.php
+++ b/include/functions2.php
@@ -2287,19 +2287,26 @@
if (!isset($_GET['debug'])) {
$cached_file = CACHE_DIR . "/js/".basename($js).".js";
- if (file_exists($cached_file) &&
- is_readable($cached_file) &&
- filemtime($cached_file) >= filemtime("js/$js.js")) {
+ if (file_exists($cached_file) && 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 {
- $minified = JShrink\Minifier::minify(file_get_contents("js/$js.js"));
- file_put_contents($cached_file, $minified);
- $rv .= $minified;
+ if ($header && $contents) {
+ list($htag, $hversion) = explode(":", $header);
+
+ 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 {
- $rv .= file_get_contents("js/$js.js");
+ $rv .= file_get_contents("js/$js.js"); // no cache in debug mode
}
}