From b6e19487b7112b93dc02f20711ca6380e1fe2e9b Mon Sep 17 00:00:00 2001 From: s2 Date: Thu, 18 Apr 2019 12:39:51 +0200 Subject: [PATCH] clean up cache right after render --- ejs-render-remote.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ejs-render-remote.js b/ejs-render-remote.js index 0871aff..dc7684d 100644 --- a/ejs-render-remote.js +++ b/ejs-render-remote.js @@ -14,12 +14,6 @@ //if the template is already cached, return it and we are done if (templateFn) { - //but first check if there is still a getter function for this template in the cache - //if yes, remove it so we clean up a bit - if (ejs.cache.remove && ejs.cache.get('getFnFor' + templateUrl)) { - ejs.cache.remove('getFnFor' + templateUrl); - } - return templateFn(data); } else { //if the template is not cached, we need to get it and render it later once we have it. remember: this happens only if the template is not already cached @@ -41,6 +35,11 @@ filename: templateUrl } )); + + //clean up the getFnFor + if (ejs.cache.remove && ejs.cache.get('getFnFor' + templateUrl)) { + ejs.cache.remove('getFnFor' + templateUrl); + } }); return '';