What is the best approach: serving static files using Express or nginx?

I create Node.js applications and I use nginx as a reverse proxy. My application has some static files that I need to serve, and a Socket.io server.

I know that I can serve static files directly using Express (using express.static middleware). I can also point nginx directly to the directory where my static files are located, so they will be served by nginx.

So the question is: which one is the best approach? What pros and cons can I encounter when using each approach?

+4
source share
2 answers

: , - , ...

: nginx, . Node/express , ... nginx. , gzip, ...

, stackoverflow : .

+9

Express , . :

Nginx node.

, , , , Express.

+2

Source: https://habr.com/ru/post/1680281/


All Articles