admin管理员组文章数量:1379528
When using jade-lang on production, would I benefit from having some form of a middleware that pre-piles all the .jade views and then uses them in res.render? Or does that automatically happen when you do NODE_ENV=production?
I'm simply exploring options on how to speed-up jade rendering on production.
When using jade-lang on production, would I benefit from having some form of a middleware that pre-piles all the .jade views and then uses them in res.render? Or does that automatically happen when you do NODE_ENV=production?
I'm simply exploring options on how to speed-up jade rendering on production.
Share Improve this question asked Mar 6, 2014 at 9:55 TheThingTheThing 1591 silver badge11 bronze badges1 Answer
Reset to default 11When Jade piles the template, the template is cached. In production environment if you warm up the cache, then there is no need to pre-pile template. Even if you don't, the template will be cached after its first pilation.
I remend you to have a look Jade's source code to better understand how it works.
exports.render = function(str, options, fn){
// ...
var path = options.filename;
var tmpl = options.cache
? exports.cache[path] || (exports.cache[path] = exports.pile(str, options))
: exports.pile(str, options);
return tmpl(options);
};
Source: https://github./visionmedia/jade/blob/1.3.0/lib/jade.js#L255-L259
exports.renderFile = function(path, options, fn){
// ...
options.filename = path;
var str = options.cache
? exports.cache[key] || (exports.cache[key] = fs.readFileSync(path, 'utf8'))
: fs.readFileSync(path, 'utf8');
return exports.render(str, options);
};
Source: https://github./visionmedia/jade/blob/1.3.0/lib/jade.js#L291-L295
本文标签: javascriptWould it benefit to precompile jade templates on production in expressStack Overflow
版权声明:本文标题:javascript - Would it benefit to pre-compile jade templates on production in express - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744452355a2606819.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论