All docs pages
Docs

Fast cache

Results that are slow to compute or fetch, kept for a while so pages stay fast.

In stackly.json and the CLI it is cache. Its use, live or draft, is counted as object and cache calls; see Live app prices.

cache · optional · needs backend · Durable Objects storage with expiry · binding APP_CACHE

Results that are slow or costly to compute or fetch, kept for a while so pages stay fast.

Turn it on

"features": ["backend", "cache"]

Use it

import { cache, cached } from "#/lib/cache.server";

const rates = await cached("fx:eur", 3600, () => fetchRates("EUR")); // runs fetchRates at most once an hour
await cache.delete("fx:eur");                                         // drop it after a change

Also cache.get(key) and cache.put(key, value, ttlSeconds). Values are JSON. null and undefined are not cached.

Limits

An hour unless told otherwise, at most 30 days.

Don't

Cache only data you can compute again. Never cache one visitor's private data under a key another visitor can reach.

All app features