I had a site where I needed to clear the cloudflare cache on each deployment. I went to the docs and found a simple request to make this happen. Thankfully, I was also using Laravel Envoyer, so all I needed to do was to add the script to my deployment hook.
curl -X POST "https://api.cloudflare.com/client/v4/zones/YOUR-ZONE-ID/purge_cache" -H "Authorization: Bearer YOUR_API_TOKEN" -H "Content-Type: application/json" --data '{"purge_everything":true}'
Here, I am purging everything, but you purge single files, cache-tags, etc.
Here is a simple curl request to clear Cloudflare cache from your deploy scripthttps://t.co/Hdn4pPLVd0 pic.twitter.com/lOgIVGQw2v
— Tim Ramsey (@tramseyjr) September 15, 2023