1.0.1 • Published 5 years ago
netlify-purge-cloudflare-cache v1.0.1
netlify-purge-cloudflare-cache
Github Repository
nikduvall/netlify-purge-cloudflare-cache
Automatically purge Cloudflare cache on Netlify deploy.
This is a fork of chrism2671/netlify-purge-cloudflare-on-deploy that I have updated to use the newer API Tokens instead of the older API Keys authentication method.
From Cloudflare, you'll need:
- Your Zone ID. Go to your Cloudflare dashboard, enter your website, and look in the bottom right hand corner under 'API'.
- Your Cloudflare API Token. See instructions below
Strictly this plugin triggers the cache purge before deploy (but after build), as this is the only functionality Netlify provides.
In Netlify, go to Settings -> Build & Deploy -> Environment -> Environment variables and set up:
- CLOUDFLARE_ZONE_ID
- CLOUDFLARE_API_TOKEN
Instructions for creating a new Cloudflare API Token
- In Cloudflare, navigate to My Profile --> API Tokens
- Click Create Token Button
- Click Custom Token Section --> Create Custom Token --> Get Started Button
- On the Create Custom Token Page:
- Token Name --> Netlify Purge Cache Token (or anything other name that is meaningful to you)
- Permissions --> Zone --> Cache Purge --> Purge
- Click Continue to Summary button
- Click Create Token Button
- Record the API Token to your password safe of choice. This is the last time you will have an opportunity to see this token.
Build failure with 'Bad request'
Check you set up your environment variables properly.
netlify.toml template
[[plugins]]
package = "./plugins/netlify-purge-cloudflare-cache"