How does enabling Draft Mode affect caching behavior for a page that is normally statically generated?
Short answer
When Draft Mode is enabled, Next.js automatically switches that page to render dynamically on every request instead of using the static cached version, ensuring editors always see the very latest draft content, while regular visitors without Draft Mode enabled continue to see…
Advertisement
AModel answer
When Draft Mode is enabled, Next.js automatically switches that page to render dynamically on every request instead of using the static cached version, ensuring editors always see the very latest draft content, while regular visitors without Draft Mode enabled continue to see the fast, cached static version.
// The same page automatically behaves differently
// depending on whether Draft Mode is active for that visitor
export default async function Page({ params }) {
const post = await getPost(params.slug);
return <Article post={post} />;
}Real-world example
An editor previewing an unpublished article always sees the freshest content thanks to Draft Mode disabling the cache for their session, while regular readers continue to get the fast, cached published version.
Likely follow-ups
- Does Draft Mode affect performance for regular visitors who are not previewing content?
- How is the Draft Mode cookie stored and how long does it last?
Related topics