在生产中禁用EJS缓存 [英] disable EJS caching in production
问题描述
似乎每当我的 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!
推荐答案
It seems like this is set explicitly as part of express
's built-in code
if (env === 'production') {
this.enable('view cache');
}
此操作由 app.init $调用c $ c>由
createApplication
调用,这是导出的函数,您可能使用 app = express()$进行调用c $ c>。您可以立即自行禁用缓存:
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屋!