Edge Cache Invalidation

Uniform provides Edge Cache invalidation API for invalidating data type caches by surrogate keys. The Kontent.ai integration collects surrogate keys for each data resource (including linked content) used in a composition.

Kontent.ai webhooks can be configured to notify Uniform about changed content and surgically invalidate affected data resources.

The Kontent.ai integration provides an endpoint to be used as a webhook URL. The endpoint collects changes from a webhook payload and invalidates data type caches using surrogate keys.

Separate webhook should be configured per data type.

URL: https://kontentai.mesh.uniform.app/api/incremental-invalidation

Required query parameters

  • projectId (e.g. 00000000-042b-47e3-95ed-2b0ac0200991)
  • dataTypeId (e.g. hero)
  • purgeKey (e.g. 00000000-ec0c-4fb2-8841-f4c87b8992bf)

tip

Example URL:
https://kontentai.mesh.uniform.app/api/incremental-invalidation?projectId=00000000-042b-47e3-95ed-2b0ac0200991&dataTypeId=hero&purgeKey=00000000-ec0c-4fb2-8841-f4c87b8992bf

info

https://kontentai.mesh.uniform.app/api/invalidation endpoint invalidates all caches for particular data type.

  • Register a new webhook (Kontent.ai documentation) using URL from previous step as a Webhook URL
  • Select Published data in the Triggers section
  • (optional) Configure Specific events for a data type or keep All events
webhook-triggers
Webhook triggers

Preview data events will be ignored.

Content item events: invalidation by Content Item ID.
Content type events: invalidation by Content Type codename.
Asset events: invalidation by Asset ID and Asset name.
Taxonomy events: invalidation by Taxonomy Group codename.
Language events: all caches for a particular data type will be invalidated.

info

You can find a list of Kontent.ai webhook events in the documentation.

Kontent.ai Delivery API may serve stale content (if content has been cached by CDN) while fetching the new content. Delivery API provides Wait for loading new content option to bypass CDN cache.

Bypassing Kontent.ai CDN cache affects API response time and rate limits.

This option can be configured in Uniform UI per data type.

wait-for-loading-new-content
'Wait for loading new content' option

CanvasClient and RouteClient use stale-while-revalidate approach by default, so API may serve stale data resources content while revalidating in background. This behavior can be changed by specifying disableSWR: true option for the client.

newer package version needed

This settings is available with @uniformdev npm packages version 19.91.0 or higher, so consider updating your Uniform packages. If that is not an option, then use an alternative: bypassCache: true.