payload-revalidate — Optimization
Keep hooks non-blocking
Section titled “Keep hooks non-blocking”Hooks enqueue targets per transaction and return immediately. Never call flush() or send() inside a collection or global hook; flush() deadlocks until the 5000 ms wait cap expires, and send() posts before transaction commit and throws on failure.
Batch bulk updates with skipRevalidate
Section titled “Batch bulk updates with skipRevalidate”For bulk updates or deletes, pass context: { skipRevalidate: true } to suppress per-document hooks and the 5000 ms transaction wait cap, then call await revalidator.send({ tags, paths }) once after the owning transaction commits.
Scope tags across locales
Section titled “Scope tags across locales”Because a save in one locale can stale other locales via non-localized fields, emit tags across ctx.locales using a non-localized identifier such as doc.id, and share a single as const CACHE_TAGS map between Payload and Next.js.
Avoid maxPerDoc: 1 on versioned collections
Section titled “Avoid maxPerDoc: 1 on versioned collections”Recovering the prior published snapshot when previousDoc is a draft requires at least two retained versions. Keep versions.maxPerDoc above 1 on collections and globals that use drafts.