6 ms·
you shouldn't use node.js to serve static files its better to use nginx for that or if you have more resources available serve your files through a content deli
by marxdeveloper 13y ago
you shouldn't use node.js to serve static files
its better to use nginx for that or if you have more resources available serve your files through a content delivery network
- johnhenry 13y agoI'm curious -- what advantages does nginx have over node for serving static files?
- andrewmunsell 13y agoHere's some benchmarks: http://stackoverflow.com/questions/9967887/node-js-itself-or-nginx-frontend-for-serving-static-files http://stackoverflow.com/questions/9967887/node-js-itself-or... Nginx is pretty well tuned for serving static files quickly and efficiently, whereas Node.js is not. At scale, you're much better off serving files through Nginx because it'll do it faster.
- wmil 13y agoIt can gzip static files automatically, resume HTTP downloads, and do other HTTP tricks that are only safe with static files. Plus it's considered more secure, and presumed to have a performance advantage.
- ricardobeat 13y agoNode can do all those tricks and more, since it's a platform for network applications. transload.it built their file upload/transcoding service on node.js. but yeah, in short nginx performs better and uses less memory.
- mcantelon 13y agoFor production node.js apps, it's pretty normal to use both. nginx ends up handling static requests, because that's what it does best, and relaying anything else to node.