Nextjs Fundamentals · Caching & Revalidation

Read-your-writes

updateTag

Read-your-writes

revalidateTag is deliberately eventual: it serves stale content first. Sometimes that is wrong. When a user saves a profile and you send them straight back to the page, they expect to see their own change immediately. updateTag gives that read-your-writes guarantee.

It is a new Server Actions-only API in Next.js 16. It expires the tagged cache and reads fresh data within the same request:

'use server';

import { updateTag } from 'next/cache';

export async function updateUserProfile(userId: string, profile: Profile) {
  await db.users.update(userId, profile);
  updateTag(`user-${userId}`);
}

The difference from revalidateTag is timing. updateTag invalidates immediately, so the user sees the change right away; revalidateTag with a profile serves stale content and refreshes in the background. Because it is scoped to Server Actions, updateTag also refreshes the calling route and invalidates the matching client cache entries, so the whole round-trip stays consistent. Reach for it in forms, user settings, and any workflow where a stale read would be confusing.

You are about to answer a short quiz on updateTag.

  1. updateTag provides read-your-writes semantics: the user sees their change immediately.
  2. Unlike revalidateTag, updateTag can only be called in a Server ___.
  3. updateTag expires the tagged cache and reads fresh data within the same request.
  4. revalidateTag serves stale content first, while updateTag invalidates immediately.
  5. updateTag also refreshes the calling route and invalidates matching ___ cache entries.
  6. updateTag is the best choice when a brief delay before the user sees their change is acceptable.