Add cache parameter

This commit is contained in:
Ivan Vazhenin
2023-11-30 16:16:12 +03:00
parent 61e830901b
commit f94d6d3253
3 changed files with 18 additions and 0 deletions

9
package-lock.json generated
View File

@@ -27,6 +27,7 @@
"handlebars": "4.7.8",
"http-shutdown": "1.2.2",
"morgan": "1.10.0",
"nocache": "^4.0.0",
"pbf": "3.2.1",
"proj4": "2.9.0",
"request": "2.88.2",
@@ -5943,6 +5944,14 @@
"resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz",
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ=="
},
"node_modules/nocache": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/nocache/-/nocache-4.0.0.tgz",
"integrity": "sha512-AntnTbmKZvNYIsTVPPwv7dfZdAfo/6H/2ZlZACK66NAOQtIApxkB/6pf/c+s+ACW8vemGJzUCyVTssrzNUK6yQ==",
"engines": {
"node": ">=16.0.0"
}
},
"node_modules/node-abi": {
"version": "3.31.0",
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.31.0.tgz",

View File

@@ -36,6 +36,7 @@
"handlebars": "4.7.8",
"http-shutdown": "1.2.2",
"morgan": "1.10.0",
"nocache": "^4.0.0",
"pbf": "3.2.1",
"proj4": "2.9.0",
"request": "2.88.2",

View File

@@ -22,6 +22,7 @@ import { serve_font } from './serve_font.js';
import { getTileUrls, getPublicUrl } from './utils.js';
import { fileURLToPath } from 'url';
import nocache from 'nocache';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const packageJson = JSON.parse(
@@ -83,6 +84,13 @@ function start(opts) {
}
const options = config.options || {};
const cacheFlag = options.cache || false;
if (!cacheFlag) {
console.log('Cache disabled');
app.use(nocache());
}
const paths = options.paths || {};
options.paths = paths;
paths.root = path.resolve(