Static server plugin for egg, base on koa-static-cache.
$ npm i egg-static --save
egg-static is a plugin that has been built-in for egg. It is enabled by default.
egg-static support all configurations in koa-static-cache. and with default configurations below:
31536000in prod env,
0in other envs
truein prod env,
falsein other envs
egg-static provides one more option:
- maxFiles: the maximum value of cache items, only effective when dynamic is true, default is
All static files in
$baseDir/app/public can be visited with prefix
/public, and all the files are lazy loaded.
- In non-production environment, assets won't be cached, your modification can take effect immediately.
- In production environment,
egg-staticwill cache the assets after visited, you need to restart the process to update the assets.
- Dir default is
$baseDir/app/publicbut you can also define multiple directory by use
dir: [dir1, dir2, ...]and static server will use all these directories.
# Questions & Suggestions
Please open an issue here.