Shitty Go HTTP server designed for static sites with RAM caching.
- Go 75.9%
- Shell 24.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .gitignore | ||
| cache.go | ||
| go.mod | ||
| go.sum | ||
| install.sh | ||
| logging.go | ||
| main.go | ||
| README.md | ||
| release.sh | ||
| server.go | ||
| utils.go | ||
| watcher.go | ||
Crankshaft
a minimal, Go high-performance HTTP static file server with RAM caching.
loads your entire site into memory on startup, serves it from RAM (for speed on static sites)
usage
Default:
./crankshaft
(serves site/, on port 80. on all addresses)
Arguements:
--port (Select with port to serve on) Default: 80
--bind (which address to serve on) Default: 0.0.0.0
--serve (select which folder or file to serve) Default ./site
Examples:
# serve a specific directory on a custom port and address
./crankshaft --port 8080 --bind 127.0.0.1 --serve ./my-site
# serve a single file
./crankshaft --port 8080 --serve ./index.html
how it works
- on startup, walks the serve directory and loads every file into RAM (under 50mb)
- files are stored in a
map[string]*cacheEntrywith their content, content-type, and a pre-compressed gzip variant - a background goroutine runs to watch for file changes and updates the cache instantly
building
go build -o crankshaft .
requires Go 1.26+ and fsnotify.
performance
by serving from RAM instead of disk, you eliminate:
- disk i/o latency on every request
- kernel context switches for file reads
- filesystem metadata lookups pre-compression means gzip is done once at load time, not per-request. This is GREAT for slow disks, or/and slow CPUs.
license
MIT