Skip to content

How to serve static files

Lloyd Brookes edited this page Jun 12, 2019 · 2 revisions

Local-web-server come with static file hosting built-in.

Host the current working directory.

$ ws

Host a separate directory.

$ ws --directory public

Set a cache-control maxage value in seconds. Use this option to learn how various caching strategies will affect your app.

$ ws --static.maxage 1000000

Set a default file extension. For example, if you have a static file at /section/sport.html, with the following option set you will be able to access the file at /section/sport. Use this option to give your assets cleaner URLs.

$ ws --static.extensions html

By default, if you supply path pointing to a directory (e.g. /posts/) local-web-server will look for an index file at /posts/index.html and serve that. Use this option to change the default index file name.

$ ws --static.index home.html
Clone this wiki locally