X-Git-Url: https://git-public.kairo.at/?p=lantea.git;a=blobdiff_plain;f=js%2Fmap.js;h=1d0c16d6056a66c23e69c01e88a6f2411194fc0d;hp=9ffc81c3f3c99bd90c701384d179a7042b9d0587;hb=5d67397a69f5d7fae21644ad938ca26aee33925b;hpb=3431f496715ba63682a820ee8cf8a63dc0f86905 diff --git a/js/map.js b/js/map.js index 9ffc81c..1d0c16d 100644 --- a/js/map.js +++ b/js/map.js @@ -649,7 +649,7 @@ function clearTrack() { var gTileService = { objStore: "tilecache", - ageLimit: 14 * 86400, // 2 weeks + ageLimit: 14 * 86400 * 1000, // 2 weeks (in ms) get: function(aStyle, aCoords, aCallback) { var norm = normalizeCoords(aCoords); @@ -659,10 +659,11 @@ var gTileService = { // We did get a cached object. aCallback(aResult.image, aStyle, aCoords); // Look at the timestamp and return if it's not too old. - if (aResult.timestamp + this.ageLimit > Date.now()) + if (aResult.timestamp + gTileService.ageLimit > Date.now()) return; // Reload cached tile otherwise. - console.log("reload cached tile: " + dbkey); + var oldDate = new Date(aResult.timestamp); + console.log("reload cached tile: " + dbkey + " - " + oldDate.toUTCString()); } // Retrieve image from the web and store it in the cache. var XHR = new XMLHttpRequest(); @@ -678,8 +679,8 @@ var gTileService = { XHR.addEventListener("load", function () { if (XHR.status === 200) { var blob = XHR.response; - gTileService.setDBCache(dbkey, {image: blob, timestamp: Date.now()}); aCallback(blob, aStyle, aCoords); + gTileService.setDBCache(dbkey, {image: blob, timestamp: Date.now()}); } }, false); XHR.send();