Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disable EJS caching in production

It seems like whenever my process.NODE_ENV is set to production, EJS templating engine will cache all my .html files. So any modifications in those files will not be displayed, unless server restarts.

app.engine('.html', require('ejs').__express);

Is there a way to disable caching template on express? Thanks!

like image 233
Saitama Avatar asked Dec 10 '22 18:12

Saitama


1 Answers

It seems like this is set explicitly as part of express's built-in code

if (env === 'production') {
  this.enable('view cache');
}

This gets called by app.init which is called by createApplication which is the function that gets exported and what you probably are calling with app = express(). You can immediately disable the caching on your own:

app = express();
app.disable('view cache');
like image 91
Explosion Pills Avatar answered Dec 28 '22 07:12

Explosion Pills