koa-better-static
A higher performance, drop in replacement for koa-static
, with a few minimal changes:
- Doesn't use koa-send, but uses an optimized version
- Supports
If-Modified-Since
header for cache/performance - Removal of
gzip
option (which checks for .gz files) - Removal of
defer
(if you want this behavior, put the middleware at the end) - No default
index
file - Requires node 4 or greater.
Installation
$ npm install koa-better-static
API
var koa = ;var app = ;app;
opts
options object.
Options
maxage
Browser cache max-age in milliseconds. defaults to 0hidden
Allow transfer of hidden files. defaults to falseindex
Default file name, defaults to noneifModifiedSinceSupport
by sending a 304 (not modified) response. Defaults to trueformat
Allow trailing slashes for directories (e.g. /directory and /directory. Defaults to true
Example
var serve = ;var koa = ;var app = ; // $ GET /package.jsonapp; // $ GET /hello.txtapp; // or use absolute pathsapp; app; console;
License
MIT