http.handlers.fastcache caches GET/HEAD responses proxy_cache-style — a RAM tier for small bodies plus a disk tier served via kernel sendfile. It does singleflight miss coalescing, stale_while_revalidate/stale_if_error, Vary variants, templated cache_key, PURGE requests plus an admin API for regex bulk purge, and Prometheus metrics.
http://localhost:9083 {
route {
fastcache {
path /var/cache/fastcache
memory_size 64MB
disk_size 1GB
ttl 1h
stale_while_revalidate 30s
max_items 100000
vary Accept-Encoding
purge_allow 10.0.0.0/8
}
reverse_proxy localhost:9081
}
}
Performance:
benchmarked side-by-side on the same machine against nginx proxy_cache, caddy + souin, and a plain caddy file_server. On cache hits fastcache reaches ~93% of nginx throughput and ~2–4× souin; on large bodies served via sendfile it beats nginx ~1.7×. The run.sh script in the repo reproduces the comparison.
Install: xcaddy build --with github.com/frontyard/fastcache, or tick it on the download page.
- Repo + docs: GitHub - frontyard/fastcache · GitHub
- Module docs: fastcache package - github.com/frontyard/fastcache - Go Packages