@wyze/koa-file-server
v3.2.2
Published
file serving middleware for koa
Downloads
3
Readme
Koa File Server
An opinionated file server. Designed to sit behind a CDN.
sha256
etags and consequential 304s- Caches
fs.stat()
calls - Caches etag calculations
- OPTIONS and 405 support
index.html
files- 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.html
fileshidden
- 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
pushOption
ispriority: 1-7
.
- The only
link
- will set link headers based onfiles
option