Giter VIP home page Giter VIP logo

egg-static's Introduction

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.

egg-static's People

Contributors

airyland avatar atian25 avatar dead-horse avatar fengmk2 avatar helloyou2012 avatar maxming2333 avatar okoala avatar popomore avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

egg-static's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.