Auto-Purge the Cloudflare Cache
On your siteโs page inside your Netlify account, navigate to the Plugins page with the menu at the top:
Then click
Go to the plugins directory.
Find the plugin,
Cloudflare Cache Purge, and click
Install.
Now youโll need to configure the plugin.
The following was taken from the
pluginโs docs:
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'.
- An API Token
API TOKEN - Instructions for creating 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.
API TOKEN - Instructions for configuring Netlify
In Netlify, go to Settings -> Build & Deploy -> Environment -> Environment variables and set up:
- CLOUDFLARE_ZONE_ID
- CLOUDFLARE_API_TOKEN
If youโve configured this correctly, the next time you push your updated code to Github, you should see a similar message in your Netlify deployment log indicating the Cloudflare cache was cleared.
Boom!
Now you can spend more time doing other things than wasting time moving files around, clearing caches, and making mistakes in the process.
Just push your code to Github, wait about 10 seconds, and everything is updated.