disable EJS caching in production

吃可爱长大的小学妹 提交于 2019-12-06 08:08:18

问题


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!


回答1:


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');


来源:https://stackoverflow.com/questions/35375276/disable-ejs-caching-in-production

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!