3.2.2 • Published 9 years ago
@wyze/koa-file-server v3.2.2
Koa File Server
An opinionated file server. Designed to sit behind a CDN.
sha256etags and consequential 304s- Caches
fs.stat()calls - Caches etag calculations
- OPTIONS and 405 support
index.htmlfiles- Optionally serve hidden files
- Caches gzipped versions of files
- SPDY Push support
Does not support:
- Dynamic files - assumes static files never change. You will have to delete files from the cache yourself if files change.
- Directory listing
- Path decoding
API
var Koa = require('koa')
var app = new Koa()
app.use(require('compress')())
app.use(require('koa-file-server')(options))Options are:
root<process.cwd()> - root directory. nothing above this root directory can be servedmaxage- cache control max ageetag- options for etagsalgorithm- hashing algorithm to useencoding- encoding to use
index- serveindex.htmlfileshidden- show hidden files which leading.spush- will automatically try and use server pushfiles[] - array of files (relative toroot) to be server pushedpushOptions{} - options to be passed to spdy push method (e.g. priority)- The only
pushOptionispriority: 1-7.
- The only
link- will set link headers based onfilesoption