Skip to content
brix.v2 stable

Search documentation

70 guides

Documentation menu
Docs / APIs and data / Data cachingRead Markdown ↗

Cache stores and edge hints

Choose provider-native shared stores for replicas and keep native data caching separate from route-level edge policy hints.

Use provider-native stores for replicas

import { createDynamoDataCacheStore } from "brix/cache/dynamodb";

const store = createDynamoDataCacheStore({
  tableName: "storefront-data-cache",
  region: "eu-west-1",
  strong: true,
});

Provision one string partition key named pk, no sort key or indexes, and TTL on expiresAt. Grant least-privilege GetItem and PutItem access. The adapter does not provision infrastructure. strong defaults to false; when true, every native GetItem uses ConsistentRead. The adapter does not use transactions.

Entries expire logically at staleUntil; provider TTL performs cleanup. Per-tag invalidation tokens live for 30 days plus 60 seconds. There are no global revisions. Entries have a conservative 380 KiB limit.

On Fastly, configure a KV store and use the request-only native adapter:

import { createFastlyKvDataCacheStore } from "brix/cache/fastly";

const store = createFastlyKvDataCacheStore({ storeName: "storefront-data-cache" });

Fastly KV has no strong-read option. With platform: "fastly", brix dev runs native KV in the real Viceroy runtime using the root fastly.toml local_server fixtures. Entry and marker TTL rules match DynamoDB. Neither adapter purges CDN or browser caches. Treat Fastly KV as provider-visible storage and avoid sensitive data unless its controls and your threat model explicitly permit it.

Both stores use separate entry and per-tag-token operations, so invalidation is eventual. They suit non-authoritative cached data where bounded staleness is acceptable, not correctness-critical state.

Route edge hints are different

const brixServer = defineBrixServer(brix, {
  cachePolicies: ["publicPage", "sharedChrome"] as const,
});

createPageRoute(pageContract, {
  cache: "publicPage",
  component: ProductPage,
});

Policy names are manifest hints, not an in-process response cache. Brix never stores route responses. Your edge maps names to provider policy and uses Brix's manifest decision helpers. Omitted cache and cache: false are uncached.

Keep user-specific pages uncached. Translation locale and HTML/Markdown representation must be in edge identity; opaque locale selection fails closed. See fragments and translations.