Documentation
Caching & CDN
Blobify writes every artifact with an explicit Cache-Control header, and CDNs respect origin headers by default. That means your caching posture is already decided unless you decide otherwise. This page explains what the defaults are and how to change them deliberately.
What Blobify sets on each artifact
There are two classes of objects in your bucket:
| Class | Artifacts | Cache-Control |
|---|---|---|
| Mutable | content/{model}/{id}/published.json, summary manifests (summaries/published/index.json), list-index manifests, lookup pointers, assets/catalog.json, schemas/manifest.json | no-store, max-age=0, must-revalidate |
| Immutable | Summary shard files, list-index page files, asset media files | public, max-age=31536000, immutable |
The split follows the pointer pattern: mutable objects are small pointers that must always be fresh, and they name versioned immutable objects that can be cached forever. Whenever content changes, Blobify writes new immutable files and updates the pointers. The immutable files themselves never change after creation.
Immutable artifacts are already optimally cached. Everything below is about the mutable class only.
Posture 1: always fresh (the default)
Do nothing. Every read of a mutable artifact goes to the bucket, and readers always see the latest published state within seconds of the queue worker converging.
This is the right choice for most sites. Reads are cheap (R2 has no egress fees and 10 million requests per month free through Cloudflare), and static-site generators only read at build time anyway. Don't add caching machinery until request volume or origin latency gives you a reason.
Posture 2: short TTL with stale-while-revalidate
If your site reads content JSON at request time (SSR, ISR misses, client-side fetches) and traffic is high, cache the mutable artifacts briefly at the edge and accept a bounded window of staleness.
With a Cloudflare Cache Rule on your bucket's domain:
When: hostname eq cdn.example.com
and ends_with(http.request.uri.path, ".json")
Then: Eligible for cache
Edge TTL: override origin, 60 seconds
Serve stale while revalidating: onPublished content is then at most ~60 seconds behind the dashboard, and origin reads drop to one per URL per minute regardless of traffic. Tune the TTL to the staleness your site can tolerate; 30–120 seconds covers most cases.
Notes:
- Scope the rule to your bucket hostname (or the path prefix you serve content from), not your whole zone.
- The rule matches immutable artifacts too, which is fine: the override is equal to or shorter than their origin header, and you can exclude them if you want their full year at the edge.
- Never write a rule that adds caching to the private tree (the
pv_...folder). Its paths are unguessable and its objects are markedno-store; leave both properties intact.
Posture 3: cache forever, purge on publish
The strongest setup: long edge TTLs on content JSON (and your rendered pages), invalidated the moment content actually changes. This is what webhook payloads are designed for: every delivery carries the affected entry's resolved page urls and stable revalidationTags.
Point a webhook at a small worker that verifies the signature (see Webhooks for the verification code) and purges the affected URLs:
// Cloudflare Worker: purge edge cache when Blobify publishes.
type BlobifyWebhookPayload = {
event: string;
space: string;
model: string;
contentId: string;
urls: string[];
};
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const rawBody = await request.text();
// Verify X-Blobify-Signature over rawBody first (code in the Webhooks doc).
const payload = JSON.parse(rawBody) as BlobifyWebhookPayload;
const files = [
// The rendered pages that show this entry.
...payload.urls.map((path) => `https://www.example.com${path}`),
// The entry's content JSON in the bucket.
`https://cdn.example.com/spaces/${payload.space}/content/${payload.model}/${payload.contentId}/published.json`,
];
await fetch(
`https://api.cloudflare.com/client/v4/zones/${env.ZONE_ID}/purge_cache`,
{
method: "POST",
headers: {
Authorization: `Bearer ${env.CF_API_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ files }),
},
);
return Response.json({ purged: files.length });
},
};If your space uses a content prefix (the default), include its cp_... segment in the content JSON URL. Copy the exact path from the dashboard or the generated client rather than hand-building it.
Because a changed entry also moves derived artifacts (summary manifests, list-index manifests, lookup pointers), either keep those on Posture 2's short TTL while giving published.json and pages the long TTL, or purge by prefix/tag where your plan supports it. The payload's revalidationTags are stable strings designed for tag-based purging and for Next.js revalidateTag.
content.unpublished, content.archived, and content.deleted deliveries carry the URLs that just stopped existing. Purge those too, so the edge doesn't keep serving removed content until the TTL runs out.
Generated-client caching
The generated client caches nothing unless you ask it to. cache defaults to 'none' in every runtime and framework, so nothing is kept between calls and every call fetches fresh from the bucket (or your CDN). Within a single call, such as one getById or getAll together with the references and assets it resolves, the client reuses a file it has already loaded instead of fetching it again for every reference. A file that fails to load is not reused, so the next lookup in the call tries it again. Two separate calls each fetch again. Choose a policy from how your site renders:
| Rendering | Option | Behavior |
|---|---|---|
| Static build or one-off script | cache: 'static' | Each file is fetched once for the life of the client and never refreshed |
| Long-running server | cache: { policy: 'ttl', maxAgeMs } | Immutable files stay cached; mutable files are refetched once older than maxAgeMs |
| Next.js | fetchOptions that passes tags to Next | Webhook revalidationTags refresh the statically rendered pages that read changed content |
| Always fresh | cache: 'none' (the default) | Every call fetches the files it needs, reuses them within that call, and keeps nothing afterwards |
With the default, nothing is kept between calls, so a build or script that makes many separate calls on one client fetches shared files, such as the asset catalog, once per call. cache: 'static' makes the build fetch each file once.
A client with neither cache nor fetchOptions set notices when separate calls have fetched the same file 5 times and logs one warning, once per page load or server process however many clients you create. The message names the kind of file, never its URL:
[Blobify] The same asset catalog was fetched 5 times by separate calls, because this client keeps nothing between calls. For a static build set cache: 'static'. For a long-running server use cache: { policy: 'ttl', maxAgeMs }. For Next.js pass fetchOptions. Set cache: 'none' to keep this behaviour and silence this warning.Setting either option turns the check off. A site that wants no caching sets cache: 'none' explicitly: reads behave exactly as they do by default, and the warning never appears.
For a static build, cache everything for the length of the build:
const client = createClient({
baseUrl: "https://cdn.example.com",
spaceId: "main",
cache: "static",
});'static' never refreshes, so it is wrong for a long-running server: a process that stays up keeps serving whatever it read first. Use it only where the process exits when the build is done.
For a long-running server, bound the staleness instead:
const client = createClient({
baseUrl: "https://cdn.example.com",
spaceId: "main",
cache: { policy: "ttl", maxAgeMs: 60_000 },
});Summary shards and list-index pages are immutable, so they stay cached. Content documents, manifests, lookup pointers, and the asset catalog are refetched once they are older than maxAgeMs, so a publish reaches the server within that window.
For Next.js, leave cache at its default and hand the client's tags to Next:
const client = createClient({
baseUrl: "https://cdn.example.com",
spaceId: "main",
fetchOptions: (_ctx, tags) => ({ next: { tags } }),
});The client passes every fetch the Blobify tags for what it reads, in the same format as the webhook payload's revalidationTags. With a fetchOptions function, a call reuses a file only for an identical request, so the same file can be fetched once per language or model within one call and every fetch carries the right tags. A statically rendered page fetches its content once, when it is built, and those tags are what let the webhook handler's revalidateTag call refresh exactly the pages that read the changed content.
Next does not cache fetch by default, so a dynamically rendered route (one that uses request-time APIs such as cookies() or headers()) fetches from the bucket on every request. To cache those reads too, opt in alongside the tags:
fetchOptions: (_ctx, tags) => ({ cache: "force-cache", next: { tags } }),Other Next fetch options, such as revalidate, go in the same next object. The handler is in the Webhooks doc.
The ttl policy is the only cache policy that records timestamps, and it does so only for mutable artifacts. The static and none policies never call Date.now() on cache read or write paths, so static caches are safe in deterministic prerendering.
Request coalescing is a separate createClient option named dedupe. It defaults to true when caching is enabled and false under cache: 'none'. With dedupe: true, concurrent requests to the same URL share one in-flight promise under any cache policy, but no settled value is retained. With dedupe: false, every request is issued independently. A single call already reuses the files it has loaded, whatever this setting, so dedupe matters mainly when separate calls run at the same time.
const client = createClient({
// ...
cache: 'none',
dedupe: true,
});Under Next.js, keep dedupe off (the default with cache: 'none') unless the client is created per render. A shared promise means a concurrently rendering second route does not issue its own fetch, so that route receives no fetch cache tag attribution.
Framework-level caching
If your frontend is Next.js, you may not need CDN configuration at all: pass the client's tags to Next with fetchOptions as shown above, and let the webhook handler call revalidateTag / revalidatePath. The complete handler is in the Webhooks doc.
Summary
| Posture | Staleness | Setup | Use when |
|---|---|---|---|
| Always fresh | none | nothing | default; build-time reads; low traffic |
| Short TTL + SWR | seconds, bounded | one CDN cache rule | request-time reads at volume |
| Purge on publish | none after purge | cache rule + webhook worker | high traffic, instant updates |