diff --git a/88-tar1090.conf b/88-tar1090.conf index 2372458..2cad44f 100644 --- a/88-tar1090.conf +++ b/88-tar1090.conf @@ -54,9 +54,9 @@ $HTTP["url"] =~ "^/INSTANCE/data/icao_.*\.json$" { "Cache-Control" => "public, max-age=10", ) } -$HTTP["url"] =~ "^/INSTANCE/db2/.*\.json$" { +$HTTP["url"] =~ "^/INSTANCE/db.*\.json$" { setenv.add-response-header += ( - "Cache-Control" => "public, max-age=100000", + "Cache-Control" => "public, max-age=1209600", ) } $HTTP["url"] =~ "^/INSTANCE/.*\.png$" { diff --git a/html/dbloader.js b/html/dbloader.js index f01eeba..1021f4a 100644 --- a/html/dbloader.js +++ b/html/dbloader.js @@ -73,7 +73,7 @@ function request_from_db(icao, level, defer) { function getIcaoAircraftTypeData(aircraftData, defer) { if (_aircraft_type_cache === null) { - $.getJSON("db2/icao_aircraft_types.json") + $.getJSON(databaseFolder + "/icao_aircraft_types.json") .done(function(typeLookupData) { _aircraft_type_cache = typeLookupData; }) @@ -136,7 +136,7 @@ function db_ajax_request_complete() { } else { _request_count++; req = _request_queue.shift(); - const req_url = 'db2/' + req.bkey + '.json'; + const req_url = databaseFolder + '/' + req.bkey + '.json'; ajaxreq = $.ajax({ url: req_url, cache: true, timeout: 30000, diff --git a/html/early.js b/html/early.js index 3174749..42799a8 100644 --- a/html/early.js +++ b/html/early.js @@ -15,6 +15,8 @@ var configureReceiver = $.Deferred(); var historyTimeout = 60; var globeIndex = 0; +var databaseFolder = "db2"; + var uuid = null; try { diff --git a/html/script.js b/html/script.js index 73536e0..db3b420 100644 --- a/html/script.js +++ b/html/script.js @@ -564,11 +564,11 @@ function initialize() { // Wait for history item downloads and append them to the buffer push_history(); // this will be needed later - $.getJSON("db2/icao_aircraft_types.json") + $.getJSON(databaseFolder + "/icao_aircraft_types.json") .done(function(typeLookupData) { _aircraft_type_cache = typeLookupData; }) - $.getJSON("db2/airport-coords.json") + $.getJSON(databaseFolder + "/airport-coords.json") .done(function(data) { _airport_coords_cache = data; const search = new URLSearchParams(window.location.search); diff --git a/install.sh b/install.sh index 432ec05..69cff12 100755 --- a/install.sh +++ b/install.sh @@ -65,6 +65,9 @@ then git reset --hard origin/master fi +cd $ipath/git-db +DB_VERSION=$(git rev-parse --short HEAD) + cd "$dir" if [[ "$1" == "test" ]] @@ -174,7 +177,8 @@ do rm -rf $html_path 2>/dev/null || true cp -r -T html $html_path mkdir -p $html_path/db2 - cp -r -T $ipath/git-db/db $html_path/db2 + cp -r -T $ipath/git-db/db $html_path/db-$DB_VERSION + sed -i -e "s/var databaseFolder = .*/var databaseFolder = \"db-$DB_VERSION\";/" $html_path/early.js mv /tmp/tar1090_config.js $html_path/config.js 2>/dev/null || true mv /tmp/tar1090_colors.css $html_path/colors.css 2>/dev/null || true diff --git a/nginx.conf b/nginx.conf index d054715..e69f35b 100644 --- a/nginx.conf +++ b/nginx.conf @@ -18,7 +18,7 @@ location /INSTANCE/data/ { } location ~ globe_.*\.json$ { gzip off; - add_header Cache-Control "public, max-age=2"; + add_header Cache-Control "public, max-age=0"; add_header Content-Encoding "gzip"; } } @@ -53,8 +53,8 @@ location /INSTANCE { gzip_static on; - location ~ db2/.*\.json$ { - add_header Cache-Control "public, max-age=100000"; + location ~ db.*\.json$ { + add_header Cache-Control "public, max-age=1209600"; } location ~ .*\.png$ { add_header Cache-Control "public, max-age=1209600";