Strapi Plugin
If you are using Strapi , the Strapi GraphQL Plugin , and Stellate , you should use our Stellate Strapi plugin , which will take care of invalidating any data you changed in your Stellate Edge Cache.
This plugin is currently in an alpha state. We would love to know how well it works for you, please let us know at support@stellate.co!
Before you start, make sure you have signed up for a Stellate account , and have created a service for your Strapi GraphQL API.
You can keep the default 15-minute cache rule in place. However, we would recommend tweaking (and adding additional) cache rules to optimize the value you get out of the Stellate Edge Cache. Keep in mind that the plugin takes care of invalidating cached responses if you make changes to your Strapi content, so you might want to increase maxAge
and swr
values considerably.
Usage
- Install the Strapi plugin:
npm install strapi-plugin-stellate
- Add the plugin to
./config/plugins.js
and add your Stellate service’s name and purging API tokenmodule.exports = { stellate: { config: { serviceName: '<yourStellateServiceName>', // REQUIRED: Your Stellate service's name purgingAPIToken: '<yourPurgingAPIToken>', // REQUIRED: Your Purging API token soft: false, // OPTIONAL: Whether you want to use soft purging }, }, }
Further Details
- The plugin handles automatic cache invalidation for all entities, including custom post types and taxonomies that are exposed via the GraphQL API.
- At the moment, the plugin purges all cached responses for a type when any single entity is created/deleted/edited. This is necessary for creations and deletions to make sure any lists containing that type are invalidated and will show accurate data.
- In the future we might optimize this for edits to only purge the specific entities.