/docs/vps/go-sidecar
Go Sidecar
What is the Go Sidecar?
The Go Sidecar is an optional high-performance reverse proxy written in Go that sits between Caddy and your Next.js process. It serves prerendered HTML pages directly from memory, handling repeated requests in under a millisecond without touching Node.js.
Request flow
Browser
โ
โผ HTTPS
Caddy (:443)
โ
โโ Static assets (/_next/static/*) โโโบ served by Caddy directly
โ
โโ Page requests โโโโโโโโโโโโโโโโโโโบ Go Sidecar (:3001)
โ
โโโโโโโโโโดโโโโโโโโโโ
โ cache hit? โ
โ < 0.5 ms โ
โโโโโโโโโโฌโโโโโโโโโโ
no โ yes
โ โโโโบ return cached HTML
โผ
Next.js (:3000)
โ
renders page
โ
sidecar caches
response + returnsCapabilities
In-memory page cache
Radix-tree keyed cache stores full HTML responses. Invalidated on deploy.
Image optimisation
Resizes and converts images to WebP/AVIF on first request, caches the result.
Transparent fallback
Cache miss or sidecar crash: Caddy falls back to Next.js directly. Zero downtime.
Worker pool
Configurable goroutine pool prevents thundering-herd on cache population.
Configuration (nextdeploy.yml)
# nextdeploy.yml
name: my-app
region: nairobi-1
gosidecar:
enabled: true
port: 3001
max_image_workers: 4
cache:
max_entries: 2000
ttl: 3600 # seconds; 0 = cache until next deploy
exclude:
- /api/*
- /dashboard/* # never cache authenticated pages
image_optimization:
enabled: true
formats: [webp, avif]
quality: 85Deploy commands
The sidecar binary is bundled with the NextDeploy CLI and uploaded during nextdeploy prepare. No separate installation needed.
# Validate config and upload the sidecar binary to your VPS nextdeploy prepare # Build your app, transfer the bundle, run health check, flip traffic nextdeploy ship # Verify sidecar is running and check cache stats nextdeploy sidecar status # Flush the page cache without redeploying nextdeploy sidecar purge