I am currently writing a node server, using express and ejs for the tempting engine. Some of my .ejs files have 7 - 8 include statements for partials nested inside of them. I was wondering if this is resource intensive, or if it will be fine.
EJS maintainer here.
First off, if you're reading the same file many times in a row, the filesystem will cache it on that level.
However, if you want maximum performance, set cache: true in the options. (docs) You must be using renderFile() or passing in the filename to get this to work. If you're using Express, cache: true is set automatically when NODE_ENV is set to production.
Keep in mind that this assumes that your files never change. i.e. if you change a file, EJS will just use the old cached version until you restart the server process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With