Skip to content
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.

Latest commit

 

History

History
34 lines (26 loc) · 1.05 KB

file-serving.md

File metadata and controls

34 lines (26 loc) · 1.05 KB

File Serving

Koala uses koa-file-server to serve static files. Unlike other static servers, this server assumes that files do not change during the lifetime of the server. If one of your static files change during runtime, it is no longer static!. Use an additional middleware to serve these dynamic files if you have any. During development, you should ideally create a middleware for your build process.

The file server also only serves from a single folder. Simply symlink any other files into this folder at start up to keep things simple. Don't try to juggle multiple static folders.

Some features of this static server:

  • Creates strong sha256 etags and caches them
  • Caches fs.stat() calls
  • Caches gzipped versions of these files

In particular, .gz versions of your static files are automatically created, so be sure to add *.gz to your .gitignore!.

options.fileServer

Where to pass all the options to the file server.

const app = koala({
  fileServer: {
    maxAge: '1 year'
  }
})