What steps can be taken to improve jade template rendering performance in express using nodejs

前端 未结 3 1582
我寻月下人不归
我寻月下人不归 2021-02-13 05:27

Background

jade syntax is awesome but i wanted to see how it was affecting performance.

So i created a single page app and used apache bench to compare its throu

3条回答
  •  悲哀的现实
    2021-02-13 06:10

    (Adding this extra bit of information since this seems to be one of the first search engine hits when looking for "express jade performance")

    I had the same issue with a nodejs production application. The problem is that jade runs by default on development mode which is not what you want for production, since this will recompile all templates again and again, wasting cpu and memory.

    The solution is to run your app with: NODE_ENV=production node app.js, this will prevent jade recompiling cycle, and perhaps trigger some other express perf improvements.

    Note that this doesn't make jade faster, it just prevents it from doing unnecessary work and killing your CPU.

提交回复
热议问题