R
R
Roman2017-02-25 21:56:52
Node.js
Roman, 2017-02-25 21:56:52

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

4 answer(s)
V
Vitaly, 2017-02-25
@vshvydky

and what prevents to make a backend through api or sockets?

L
Leo Developer, 2017-02-25
@crazy_leo

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)

A
Artem Mozharov, 2017-02-25
@werftgyhj

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.

M
Michael, 2017-02-26
@mak_ufo

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 question

Ask a Question

731 491 924 answers to any question