Static files

ingenium.static serves files from a directory with the production-grade primitives you'd expect: weak ETags, conditional GET, range requests, MIME-from-extension, and path-traversal protection.

Usage

app.use(ingenium.static('./public', {
  index: 'index.html',     // default; set false to disable
  maxAge: 60_000,          // ms - sets Cache-Control: public, max-age=60
  extensions: ['html'],    // try /foo + /foo.html when /foo not found
  dotfiles: 'ignore',      // 'allow' | 'deny' | 'ignore' (default: ignore → next())
}))

What's included

  • Weak ETags - W/"size-mtime" for cheap, accurate invalidation.
  • Conditional GET - If-None-Match → 304 when the ETag matches.
  • Range requests - Range: bytes=N-M → 206 Partial Content.
  • MIME from extension - built-in mapping, extensible.
  • Path-traversal protection - ../etc/passwd → 403.

Known gaps

  • Static middleware does not currently honor If-Modified-Since - only If-None-Match.
  • HEAD requests on static files fall through to next() instead of returning headers-only.

Both are tracked in the roadmap.

Where to next?