Contentful Cache Configuration
We recommend using Contentful webhooks to purge the cache and a Stellate configuration with a long cache max age.
Stellate Configuration
import { Config } from 'stellate'
const config: Config = {
config: {
// ... other config fields
rules: [
{
types: ['Query'],
// this rule caches content for 1 year. This is safe as the webhook will
// purge the cache whenever there is a change in the content.
maxAge: 31536000,
swr: 60,
description: 'Cache everything (default)',
},
],
},
}
export default config
Contentful Webhook Configuration
-
Set the URL as a POST request to your stellate Purging URL
https://admin.stellate.co/<your_service_name>
-
Set Triggers as “Trigger for all events”
-
Generate a Purging token in your Stellate service settings
-
Set the header
stellate-token
with the generated token -
Add the following custom webhook payload:
{
"query": "mutation ContentfulWebookPurging {\n_purgeAll\n}",
"operationName": "ContentfulWebookPurging"
}
Enjoy caching!
After both of these steps, your API should be ready and faster than ever. Learn more about our purging API .
Last updated on