nano-web
Static file server. Pre-loads and pre-compresses everything at startup for zero-latency serving.
Why
Most static file servers read from disk on every request, relying on OS page cache. This works fine until you need consistent low latency under load. nano-web loads everything into memory at startup with pre-computed compressed variants, so serving a file is just a hashmap lookup and a buffer copy.
Performance
~150k req/sec on M3 Max, sub-millisecond latency. The server does almost nothing per-request by design.
wrk -c 50 -d 10 -t 50 http://localhost:3000
Latency 328.63us 47.98us 2.86ms 88.05%
Req/Sec 3.01k 103.63 3.21k 91.58%
1513328 requests in 10.10s, 8.58GB read
Requests/sec: 149838.48
Install
# mise
# cargo
# or grab a binary from releases
Usage
Docker
FROM ghcr.io/radiosilence/nano-web:latest
COPY ./dist /public/
~5MB image. Multi-arch.
Configuration
| Flag | Default | Description |
|---|---|---|
--port, -p |
3000 |
Port |
--spa |
false |
Serve index.html for missing routes |
--dev, -d |
false |
Reload files on change |
--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 environment variables into HTML at startup. Useful for deploying the same build to different environments.
Variables matching the prefix (default VITE_) get injected. Available template vars:
{{env.VAR_NAME}}- single variable{{Json}}- all vars as JSON object{{EscapedJson}}- escaped for use in strings
Health Check
GET /_health returns {"status":"ok","timestamp":"..."}.
License
MIT