Published

How I Built a Distributed Build Cache

October 26, 20254 min read

“bro i swear to fkn god if i have to wait another 10 minutes for a next build im gonna fkn lose it”
— me, 2:17 AM, hackathon day 1

i didn’t set out to build a product.
i set out to stop waiting.


The Hackathon That Broke Me

it was my first-ever hackathon.
me, Sunrit, and Aditya — three devs, one next.js app, zero patience.

we were building a full-stack app in 48 hours.

every time we changed a component:

npm run build

10–15 minutes.

we’d push, wait, context-switch, forget what we were doing, come back, repeat.

15 minutes per build × 20 builds = 5 hours lost.
5 hours = ~10% of the entire hackathon.

even tho we made the top 5, what stuck with me was the fact that so much of our time got wasted in just building the project over and over and over again.


The Rage Was Real

fast forward a few months.
i’m solo on a new next.js project.
same story:

  1. change a line of css
  2. npm run build
  3. wait a SHIT TON
  4. context-switch to twt
  5. come back like nothing happened

that’s not a dev loop.
that’s emotional damage.

so i said:

“i’m gonna build my own cache in go. just to learn.”

this was also supposed to be our next hackathon project — a build cache to crush the competition.
but the hackathon got canceled.

so i built it anyway.


Why Go?

i wanted to learn Go the hard way.
not “Hello World”.
not “write a web server”.

i wanted:

  • real concurrency
  • file i/o at scale
  • cli ux
  • single binary distribution

so i picked the hardest problem i could think of:
make builds instant.


The Core Idea: Fingerprint → Cache → Restore

$ velocity run build

that’s it.

behind the scenes:

  1. fingerprint your project (files + env + command)
  2. check local cache (.velocity/cache/)
  3. check remote cache (public S3/R2)
  4. hit? → unzip outputs → done in 2.1s
  5. miss? → run command → zip outputs → save + upload async

no daemons. no agents. just a single binary.

Install in 10 seconds

go install github.com/bit2swaz/velocity-cache@latest

The MVP: 2 Days, <10 Hours, Solo

i originally planned a "69 days of building" sprint with Sunrit.
you know — dramatic, public, full arc.

then i started coding.

day 1 (~4 hours):

  • scaffolded the cli
  • built config loader
  • wrote deterministic file hasher with goroutines
  • got local caching working

day 2 (~4.5 hours):

  • added public S3 remote (async upload)
  • built velocity init, run, clean
  • polished logs with color
  • wrote README + GIF

done.

total time: ~9 hours.
total commits: ~10.
total lines: A LOT.

i thought this would be hard.
turns out go makes hard things feel easy.


velocity init

$ velocity init
Wrote velocity.config.json.example

drop this in your project root:

{
  "scripts": {
    "build": {
      "command": "npm run build",
      "inputs": ["src/**/*", "package.json"],
      "outputs": [".next/"],
      "env_keys": ["NODE_ENV"]
    }
  }
}

velocity run build

Cache Hit (The Magic)

Cache Hit Terminal Remote

Cache Hit Terminal Local ↑ 33ms. feels like cheating.

Cache Miss (First Run)

Cache Miss Terminal ↑ live streaming. async upload. no blocking.


velocity clean

$ velocity clean
Purged .velocity/cache/

The Tech

  • Cobra → cli
  • Viper → config
  • doublestar → globs
  • goroutines → concurrent file hashing
  • SHA256 → deterministic cache keys
  • S3/R2 → remote cache (public bucket for MVP)
  • fatih/color → pretty logs

all in pure Go.
one binary. no runtime. no node. no python.


The "Oh Shit" Moment

halfway through day 1, i realized:

this isn’t just a learning project.
this is a real product.

developers are paying thousands in CI bills.
engineering managers are begging for faster feedback loops.
teams are wasting hours every sprint.

And i had a tool that:

  • saved minutes per build
  • worked locally and remotely
  • required zero config beyond one json file

i wasn’t just learning Go.
i was accidentally building a product.


The Vision (Now That I See It)

Phase 1: MVP (Done in 2 Days)

  • open-source cli
  • local + public remote cache
  • go install → instant setup

Phase 2: SaaS (Next)

  • velocity login
  • private team caches
  • web dashboard: time Saved, hit rate, ROI
  • billing: $29/mo per team

Phase 3: Enterprise

  • monorepos
  • SSO
  • on-prem

all built by me. solo. in public.


Try It. Break It. Tell Me.

go install github.com/bit2swaz/velocity-cache@latest
velocity init
# edit velocity.config.json
velocity run build

Repo: github.com/bit2swaz/velocity-cache
Issues: Open one. I’ll reply in <24h.
Twitter/X: @bit2swaz


Final Thought

i started this because a hackathon broke me.
i finished it in 2 days because Go is that good.

and now? i’m not stopping.

velocitycache is open-source today.
it could be a SaaS tomorrow.
and i’m building it all in public.

if you’re a dev who hates waiting — try it.
if you’re a founder who sees the vision — hit me up.

we’re just getting started.


— bit2swaz
githubtwt/x