Runtime & Infrastructure
Caching
Caching — Runtime & Infrastructure documentation for BCP Framework.
Last updated: 2026-08-30T23:15:12
Caching and Revalidation
Route response cache
A page or API route can opt into production response caching:
export const revalidate = 60;Values:
number > 0 cache for that many seconds
false cache until explicitly invalidated
0 disable route response cachingBCP returns X-BCP-Cache values such as MISS, HIT and BYPASS for cache-enabled production routes.
Requests containing credentials or explicit no-cache directives bypass the shared response cache. Responses that set cookies or are explicitly private/no-store are not stored when the route semantics require respecting the response policy.
Data cache
import {
cache,
} from "bcp/cache";
const loadUser = cache(
async (id: string) => {
return database.user.find(id);
},
{
key: "user",
revalidate: 60,
tags: ["users"],
paths: ["/users"],
}
);Concurrent calls for the same cache key share in-flight work.
Request-scoped dedupe
import {
dedupe,
} from "bcp/cache";
const loadSession = dedupe(
async () => loadCurrentSession(),
"current-session"
);dedupe() shares work only inside a request context.
Invalidation
import {
revalidatePath,
revalidateTag,
} from "bcp/cache";
revalidateTag("users");
revalidatePath("/dashboard");Path invalidation clears the matching path and descendants.
Current deployment limitation
The cache runtime is in-memory and process-local. Restarting the Node.js process clears it, and multiple application instances do not share cache state or invalidation events. A distributed adapter such as Redis is a future extension rather than part of the current release.