WordPress plugin that integrates WPGraphQL with Cloudflare's cache purge API. It adds Cache-Tag headers to GraphQL responses and automatically purges those tags via Cloudflare when content changes.
- WordPress 5.6+
- PHP 7.4+
- WPGraphQL 1.16.0+
- WPGraphQL Smart Cache (provides the
graphql_purgeaction that triggers purges)
- Cache-Tag headers -- On every GraphQL response, the plugin copies WPGraphQL's
X-GraphQL-Keysheader into aCache-Tagheader that Cloudflare reads for tag-based caching. - Automatic purging -- When content changes in WordPress, WPGraphQL Smart Cache fires a
graphql_purgeaction with the relevant cache keys. This plugin sends those keys to Cloudflare's/purge_cacheAPI to invalidate only the affected cached responses.
- In the WordPress admin, go to GraphQL > Settings > Cloudflare.
- Enter your Zone ID (how to find it).
- Enter a Cloudflare API Token with
Zone.Cache Purgepermission (create one here). - Check Enable Cloudflare Revalidation.
composer install
npm install
npm start # starts WordPress at http://localhost:8888
npm run seed # creates sample posts, pages, categories, and tagsWP Admin: http://localhost:8888/wp-admin/ (username: admin, password: password)
GraphQL endpoint: http://localhost:8888/index.php?graphql
The environment comes with WPGraphQL, WPGraphQL Smart Cache, and this plugin pre-activated.
| Command | Description |
|---|---|
npm start |
Start the WordPress environment |
npm run seed |
Populate sample content (idempotent) |
npm stop |
Stop the environment |
npm run destroy |
Remove all containers and data |
composer phpcs |
Run PHP linting (WordPress/VIP coding standards) |
composer phpcbf |
Auto-fix lint issues |
- Conventional Commits enforced by a local git hook
- PRs are squash-merged to
main-- the PR title becomes the commit message