Skip to content

How to serve static files

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

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 affect your app.

$ ws --static.maxage 1000000

Set a default file extension. With the following option set, the static file /section/sport.html will also be accessible at /section/sport. Use this option to give your assets cleaner URLs.

$ ws --static.extensions html

In the case the path requested does not include a filename (e.g. /, /posts/ etc) local-web-server will look for the default index filename (index.html). Use this option to change the default index file name.

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