From 865503d8b6a19738aeaa44b71cb0bfc16b7592ed Mon Sep 17 00:00:00 2001 From: Christian Helbling Date: Thu, 16 Apr 2015 11:42:36 +0200 Subject: make short expire an option as itjs::checksum usage is different depending on whether we have the checksum in the url or not --- itjs.class | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/itjs.class b/itjs.class index 5d9cd62..f20a3b7 100644 --- a/itjs.class +++ b/itjs.class @@ -193,12 +193,14 @@ static function strip($code) * @param $fnlist Either comma separated url or array of filenames to calculate checksum for * @return Checksum for given files */ -static function checksum($fnlist) +static function checksum($fnlist, $p = array()) { + $p += array('short_expire' => true); + $filenames = array_merge(is_array($fnlist) ? $fnlist : itjs::filenames($fnlist), array("/www/lib.search.ch/var/jquery-ui/dist/minified/jquery.ui.core.min.js", "/www/lib.search.ch/var/jquery/dist/jquery.min.js")); # jquery files included by lib/jquery.js $key = "itjs_" . md5(join("", it::map('"$v" . @filemtime("$v")', $filenames))); - if (time() - max(@array_map('filemtime', $filenames)) < 60) + if ($p['short_expire'] && (time() - max(@array_map('filemtime', $filenames)) < 60)) return "-"; # trigger short expire, our file may not yet be up to date on other slaves else return it_cache::get($key) ?: it_cache::put($key, substr(md5(self::filecontents($filenames, false)), 0, 10), array('ttl' => 60)); -- cgit v1.2.3