Closed DJviolin closed 8 years ago
Duplicate of #2959
Yes, there are sync parts of the res.render
API (which sucks), but it will be addressed in Express 5.0, as we cannot address it without breaking the view engine compatibility.
Starting your application with NODE_ENV=production
or setting the cache to true for rendering will cause file system activities only once per view at startup, which makes this a non-issue while the application is fully running in production, since no sync file systems are called since the views are cached.
Please also see the comments in the duplication issue @DavidTPate pointed out :)
You can also find all this information, from using the trace sync flag to how to properly setup your Express application in production on the website: http://expressjs.com/en/advanced/best-practice-performance.html
Starting your application with NODE_ENV=production or setting the cache to true for rendering will cause file system activities only once per view at startup
Wow, this is really useful to know! Probably I needed to spend a lot of time to figure out why my handlebars templates only refreshed on server reload, didn't realising that few days ago I added production
environment variable to my OS! :)
But is there a way to set express-handlebars
templating engine for always refresh from the disk on refresh? After all, this is don't needed when my static site goes to production (blog posts already read from a json file which is cached on every browser reload), but it will be good to know how I can turn on the viewing template reload on every browser load.
I enable the
--trace-sync-io
flag for Node to trace synchronous calls. It gives error for everyres.render
in my app.Maybe not connected for this error, but my express-handlebars templates only be refreshed if I restart the server.
Here is the router:
This is the console log: