How it works
Purge Patrol is a tool that sets up a long-running listener connected to your Sanity.io project. It listens for changes to your content using the Live Content API and sends a request to your Next.js application to expire the cache for the queries that are being used.
Getting started
Replace your Sanity client in the Next.js application
Instead of using the Sanity client directly, use the one provided by
defineLiveas described in the next-sanity package. This will automatically add cache tags to all queries.Set up a cache expiration API route
Set up a cache expiration API route in your Next.js application to make sure the cache expires. See example below.
Add a purger
Add a purger in Purge Patrol to automatically trigger cache invalidation when content changes.