diff --git a/src/node/eejs/index.js b/src/node/eejs/index.js index bfb445de2..057c24c75 100644 --- a/src/node/eejs/index.js +++ b/src/node/eejs/index.js @@ -24,6 +24,7 @@ var fs = require("fs"); var path = require("path"); var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks.js"); var resolve = require("resolve"); +var settings = require('../utils/Settings'); const templateCache = new Map() @@ -118,17 +119,24 @@ exports.require = function (name, args, mod) { args.require = require; let template - if (!templateCache.has(ejspath)) { + if (settings.maxAge !== 0){ // don't cache if maxAge is 0 + if (!templateCache.has(ejspath)) { + template = '<% e._init(__output); %>' + fs.readFileSync(ejspath).toString() + '<% e._exit(); %>'; + templateCache.set(ejspath, template) + } else { + template = templateCache.get(ejspath) + } + }else{ template = '<% e._init(__output); %>' + fs.readFileSync(ejspath).toString() + '<% e._exit(); %>'; - templateCache.set(ejspath, template) - } else { - template = templateCache.get(ejspath) } exports.info.args.push(args); exports.info.file_stack.push({path: ejspath, inherit: []}); - - var res = ejs.render(template, args, { cache: true, filename: ejspath }); + if(settings.maxAge !== 0){ + var res = ejs.render(template, args, { cache: true, filename: ejspath }); + }else{ + var res = ejs.render(template, args, { cache: false, filename: ejspath }); + } exports.info.file_stack.pop(); exports.info.args.pop();