Content publishing architecture
What you need to know
A publishing platform separates editorial drafts from publicly visible content. Next.js can cache published pages, but preview and publication need distinct trust and freshness policies.
By the end, you can: separate drafts and public cached pages; plan invalidation.
Read the draft mode flag in a server context
import {draftMode} from 'next/headers';export async function previewRequested(){ const {isEnabled} = await draftMode(); return isEnabled;}Expected behavior: Returns the preview flag, not authorization. An editor check must precede any draft data lookup.
How it works
Keep editorial revision state in durable storage and make the public query explicitly select published content. Use a separate preview route for authorized editors, with request-specific data and a no-store response where appropriate. Next.js Draft Mode allows a route to opt out of ordinary static delivery for preview; await draftMode() is the modern async API. The draft cookie is not proof of editor permission; check the session and requested document at preview entry and on every draft read. Redirect only to known internal paths. Public metadata and sitemap generation must query the published projection, not draft rows. Commit a publication transaction before invalidating cache. With modern revalidateTag(tag, 'max'), a later visit may see stale content while fresh data is loaded; that is suitable only when the permitted staleness matches the content policy. For immediate removal of sensitive content, design a stronger purge or deny path covering all delivery layers; a tag is not a deletion guarantee. An independent CDN can retain its own cached response until expiration or a separate purge; Next.js server cache invalidation alone does not establish that the CDN has removed it. Record a durable publication event for retry if invalidation fails after commit. A database rollback must not be reported as a successful publication.
A post-commit invalidation adapter
import {revalidateTag} from 'next/cache';export function markPublicCatalogStale(){ revalidateTag('public-catalog', 'max');}Expected behavior: Use in an appropriate Server Function or Route Handler after a durable publication commit. It marks matching entries stale, and only affects cache entries associated with that tag.
Common mistake
Do not call revalidateTag before a transaction commits or assume its return proves all CDN and browser entries are gone. Never publish previews in a sitemap.
Practice and verification
Model draft, publish, invalidation failure, retry and unpublish as separate states. Specify which responses must be fresh, which can be stale and what evidence proves an unauthorized visitor cannot view the draft.
Scope: Proposed Next.js 16.x / React 19; App Router, Cache Components disabled unless noted. Framework and browser examples are staged, not executed. No exact patched dependency release or live deployment verified.