Uniform provides an out-of-the-box (OOB) cache revalidation handler for projects using the Next.js App Router. This means you do not need to implement custom revalidation logic for Uniform-related content updates—Uniform handles cache invalidation automatically via its provided handler and a next.js tagging mechanism.
This article explains how cache invalidation works in the Uniform SDK for the canvas-next-rsc packages, how tags are generated and applied, and what happens when content changes in Uniform.
For the App Router, Uniform ships with a ready-to-use handler (createPreviewPOSTRouteHandler
). This handler processes webhook payloads from Uniform and triggers cache revalidation for affected routes and compositions. You do not need to add extra revalidation logic for Uniform content updates—just use the provided handler.
Uniform’s SDK clients for App Router (@uniformdev/canvas-next-rsc) relies on next.js tagging system that enables granular cache invalidation. Tags are attached to fetch requests made by the SDK clients, and these tags are later used to determine which cache entries should be revalidated when content changes.
Adds tags with the prefix composition: followed by the composition ID.
Example for compositionId 12345678
:
Adds tags with the prefix path: for each segment of the requested path, as well as a general route tag.
Example for /shop/category/TV-1234:
The route tag is used to revalidate all Uniform-related fetches, especially when a pattern composition is updated.
Add tags such as manifest as appropriate for their data.
When Uniform content is updated (e.g., a composition is changed or a project map node is updated), the webhook handler receives a payload describing the change. The handler then determines which tags and paths are affected and triggers revalidation for those cache entries.
Suppose you have a dynamic route in Uniform:
/shop/category/:product
Fetched Paths:
/shop/category/TV-1234
/shop/category/TV-4321
For each fetch, the following tags are generated:
route
path:
path:/shop
path:/shop/category
path:/shop/category/TV-1234 (or path:/shop/category/TV-4321)
When a composition or route is updated:
route
tag, ensuring all related fetches are invalidated./shop/category/:product
changes, the handler will revalidate path:/shop/category
, which covers all children under that category.Note: This article applies to the Next.js App Router and the Uniform canvas-next-rsc
SDK. For the Page Router, refer to the corresponding documentation.