pluginfw/performance: Dont cache if max age is 0 (#4098)
This commit is contained in:
parent
3e78b79d9d
commit
93829b9e33
1 changed files with 14 additions and 6 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue