make fresh mode the default behaviour

This commit is contained in:
ansuz
2019-08-30 15:03:22 +02:00
parent fcab0d4b6e
commit 1ec1d8b0e0
2 changed files with 20 additions and 7 deletions

View File

@@ -38,22 +38,34 @@ var app = debuggable('app', Express());
var httpsOpts;
var DEV_MODE = !!process.env.DEV
if (DEV_MODE) {
console.log("DEV MODE ENABLED");
}
// mode can be FRESH (default), DEV, or PACKAGE
var FRESH_MODE = !!process.env.FRESH;
var FRESH_KEY = '';
if (FRESH_MODE) {
var FRESH_MODE = true;
var DEV_MODE = false;
if (process.env.PACKAGE) {
// `PACKAGE=1 node server` uses the version string from package.json as the cache string
console.log("PACKAGE MODE ENABLED");
FRESH_MODE = false;
DEV_MODE = false;
} else if (process.env.DEV) {
// `DEV=1 node server` will use a random cache string on every page reload
console.log("DEV MODE ENABLED");
FRESH_MODE = false;
DEV_MODE = true;
} else {
// `FRESH=1 node server` will set a random cache string when the server is launched
// and use it for the process lifetime or until it is reset from the admin panel
console.log("FRESH MODE ENABLED");
FRESH_KEY = +new Date();
}
config.flushCache = function () {
FRESH_KEY = +new Date();
if (!config.log) { return; }
config.log.info("UPDATING_FRESH_KEY", FRESH_KEY);
};
const clone = (x) => (JSON.parse(JSON.stringify(x)));
var setHeaders = (function () {