nano-web
Static file server. Pre-loads and pre-compresses all files at startup for near-zero latency serving.
Performance
- Raw hyper (no framework overhead)
- SO_REUSEPORT for multi-core scaling
- Files pre-compressed at startup (brotli/gzip/zstd)
- Lock-free concurrent routing (DashMap + foldhash)
- Zero-copy responses (Bytes)
Benchmark (M3 Max):
wrk -c 50 -d 10 -t 50 http://localhost:3000
Requests/sec: 149838.48
Latency: 328.63us avg
Install
# mise
# cargo
Pre-built binaries on GitHub Releases.
Docker
FROM ghcr.io/radiosilence/nano-web:latest
COPY ./dist /public/
Usage
Options
| Flag | Default | Description |
|---|---|---|
--port, -p |
3000 |
Port |
--spa |
false |
Serve index.html for unknown routes |
--dev, -d |
false |
Reload modified files |
--config-prefix |
VITE_ |
Env var prefix for template injection |
--log-level |
info |
debug/info/warn/error |
--log-format |
console |
console/json |
--log-requests |
false |
Log each request |
Runtime Config Injection
Inject env vars into HTML at startup:
Variables: {{env.VAR_NAME}}, {{Json}}, {{EscapedJson}}
Caching
ETag and If-None-Match supported - returns 304 Not Modified when content hasn't changed.
Security Headers
All responses include: X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Strict-Transport-Security, Permissions-Policy, X-DNS-Prefetch-Control. Compressed responses include Vary: Accept-Encoding.
Health Check
/_health returns {"status":"ok","timestamp":"..."}
License
MIT