From 30ecb93b19237a165474079710da43573159362e Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Mon, 2 Sep 2013 21:20:44 +0100 Subject: [PATCH] tile data cache - reduce size on mobile (due to limited RAM), and increase on desktop --- code/map_data_cache.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/code/map_data_cache.js b/code/map_data_cache.js index 030effc6..2b221f41 100644 --- a/code/map_data_cache.js +++ b/code/map_data_cache.js @@ -4,8 +4,16 @@ window.DataCache = function() { this.REQUEST_CACHE_FRESH_AGE = 90; // if younger than this, use data in the cache rather than fetching from the server this.REQUEST_CACHE_MAX_AGE = 60*60; // maximum cache age. entries are deleted from the cache after this time - this.REQUEST_CACHE_MIN_SIZE = 200; // if fewer than this many entries, don't expire any - this.REQUEST_CACHE_MAX_SIZE = 2000; // if more than this many entries, expire early + + if (L.Browser.mobile) { + // on mobile devices, smaller cache size + this.REQUEST_CACHE_MIN_SIZE = 200; // if fewer than this many entries, don't expire any + this.REQUEST_CACHE_MAX_SIZE = 1000; // if more than this many entries, expire early + } else { + // but on desktop, allow more + this.REQUEST_CACHE_MIN_SIZE = 500; // if fewer than this many entries, don't expire any + this.REQUEST_CACHE_MAX_SIZE = 4000; // if more than this many entries, expire early + } this._cache = {};