Socket
Socket
Sign inDemoInstall

egg-static

Package Overview
Dependencies
Maintainers
12
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-static

static server plugin for egg


Version published
Maintainers
12
Created
Source

egg-static

NPM version Test coverage npm download

Static server plugin for egg, base on koa-static-cache.

Install

egg-static is a plugin that has been built-in for egg. It is enabled by default.

Configuration

egg-static support all configurations in koa-static-cache. and with default configurations below:

  • prefix: '/public/'
  • dir: path.join(appInfo.baseDir, 'app/public')
  • dynamic: true
  • preload: false
  • maxAge: 31536000 in prod env, 0 in other envs
  • buffer: true in prod env, false in other envs

egg-static provides one more option:

  • maxFiles: the maximum value of cache items, only effective when dynamic is true, default is 1000.

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-static will cache the assets after visited, you need to restart the process to update the assets.
  • Dir default is $baseDir/app/public but you can also define multiple directory by use dir: [dir1, dir2, ...] or dir: [dir1, { prefix: '/static2', dir: dir2 }], static server will use all these directories.
// {app_root}/config/config.default.js
exports.static = {
  // maxAge: 31536000,
};

Questions & Suggestions

Please open an issue here.

License

MIT

Contributors


dead-horse


fengmk2


atian25


popomore


okoala


airyland


helloyou2012


maxming2333

This project follows the git-contributor spec, auto updated at Sun Feb 12 2023 17:38:47 GMT+0800.

Keywords

FAQs

Package last updated on 13 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc