Search code examples
node.jsproduction-environment

Going in production: how to serve my static assets without NodeJS?


In development I used to have my Node server serve my static files (img, pdf, etc.) but as production is getting closer, I feel it is very inefficient and puts an unneeded load on Node.
What is the right way to have my assets served by a different server? Is there a ready-made solution? Should I use a "good old" Apache-PHP stack? What should I know about ports forwarding and stuff like that?

Thanks a lot!


Solution

  • I've seen this done several ways.

    1. Use Nginx to serve the static assets. Faster than Apache for static assets.
    2. Use S3 and Cloudfront to serve static assets. You'll upload your assets to S3 and enable Cloudfront to be a CDN.
    3. Use Cloudflare, I'm less experienced with this method so can't tell you much accept they handle CDN and I believe some caching.

    Hope this helps.