Answer the question
In order to leave comments, you need to log in
How to properly serve HTML with node.js+express?
What approach is considered correct when developing a site on node.js regarding the issuance of HTML pages - just give it as static or render through a template engine?
The site will be built using angular so there is no need for me to generate html on the server side.
Answer the question
In order to leave comments, you need to log in
It is much better and easier in the end to give the file as a static file, i.e. not to use a template engine on the server.
I don't see any point in rendering on the server at all. This is both a long time and a load on the server and more traffic (For example, we render news blocks, for example, there are 10 of them, through a cycle, the html code has increased 10 times, thereby traffic)
It's much better to write a REST API that will only return data. This way you will have a client separate from the server. And don't care what the client will be on ... on Angular, React, Ember, etc.
It is better to give statics through nginx. Yes, even if express, koa, etc. can do it.
If there is some kind of dynamic content, then it’s better to just make queries to the database, and on the client to compose all this data from the database using angular, react, etc.
But for the horizons, it’s better to study server rendering (using jade, for example). It will not be worse
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question