StoicBuilder

HandbookII the ForumCaching

IIthe Forum, The shape of an app

Caching

1 min readUpdated 28 November

In plain words

Caching means saving a copy of something slow to fetch, such as a page, an image or a query result, and reusing that copy until it's considered too old.

Where you see it

You fix a typo, deploy, refresh, and the old typo is still there. Somewhere between you and the server, your browser, a network like Cloudflare or the framework's own cache is still serving a saved copy.

app/posts/page.tsxserver
// Next.js: refresh this page's data at most once a minuteexport const revalidate = 60;
For up to a minute everyone gets the same saved copy. After that, the next visit triggers a fresh one.

What goes wrong

  1. Saving data without refreshing the cached page

    The post is in the database but the feed shows a copy from before it. In Next.js, the code that saves should also call revalidatePath for that page.

  2. Caching something personal

    A cached page that includes one member's name or orders can be served to the next visitor. Anything per-user must never go into a shared cache.

  3. Calling it fixed after a hard refresh

    A hard refresh skips your own browser's saved copy. Your visitors' browsers still hold theirs until it expires.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Tell me every place this app caches data, for how long and what clears it. Make sure saving something updates the page straight away, and that nothing personal to one user is cached for anyone else.

Quick check

Sign in to earn +10 XP for it

On Chirp, new posts only appear in the feed about a minute after they're published. What's holding them back?

Got a prompt that touches caching?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.