在生产中禁用EJS缓存 [英] disable EJS caching in production

查看:112
本文介绍了在生产中禁用EJS缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎每当我的 process.NODE_ENV 设置为 production 时,EJS模板引擎就会缓存我的所有。 html文件。因此,除非重新启动服务器,否则不会显示这些文件中的任何修改。

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

是否可以禁用Express上的缓存模板?谢谢!

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

推荐答案

似乎是此设置是 express 内置代码的一部分

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

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

此操作由 app.init createApplication 调用,这是导出的函数,您可能使用 app = express()。您可以立即自行禁用缓存:

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

这篇关于在生产中禁用EJS缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆