Last Updated: February 25, 2016
·
384
· crungmungus

Quickly serve up static assets with node

Previously when I wanted to quickly serve up some HTML/JavaScript I'd use a boilerplate Express app but it's actually even easier to use the http-server package.

Globally install the awesome http-server package

npm install -g http-server

Then run this from the folder with your assets

http-server -c-1

"-c Set cache time (in seconds) for cache-control max-age header, e.g. -c10 for 10 seconds (defaults to '3600'). To disable caching, use -c-1."

For more info see:

https://github.com/indexzero/http-server

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside