diff options
author | Florian Pritz <bluewind@xinu.at> | 2015-05-28 15:04:12 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-05-28 18:10:13 +0200 |
commit | 2937bf1a47778ad1b804fee65ff3c9fe5c35ab61 (patch) | |
tree | 7ad8937ba44432bcdf1e2fea5a88be888093f308 | |
parent | 26c4a4726e5fd6d682b75e1234cd780dd1d0b1c1 (diff) |
JS: Use newest file time for cache buster0.9.2
Really no need to reload the files with each page load.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r-- | application/helpers/filebin_helper.php | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/application/helpers/filebin_helper.php b/application/helpers/filebin_helper.php index 563364d32..c1f302da3 100644 --- a/application/helpers/filebin_helper.php +++ b/application/helpers/filebin_helper.php @@ -137,8 +137,26 @@ function link_with_mtime($file) function js_cache_buster() { - $minified_main = FCPATH.'/data/js/main.min.js'; - return file_exists($minified_main) ? filemtime($minified_main) : time(); + $jsdir = FCPATH.'/data/js'; + $minified_main = $jsdir.'/main.min.js'; + if (file_exists($minified_main)) { + return filemtime($minified_main); + } + + $ret = 0; + + $it = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($jsdir), RecursiveIteratorIterator::SELF_FIRST); + + foreach ($it as $file) { + $mtime = $file->getMTime(); + if ($file->isFile()) { + if ($mtime > $ret) { + $ret = $mtime; + } + } + } + return $ret; } function handle_etag($etag) |