Tips & Tricks: Purge Cloudflare cache via Webhook payload customization

Here’s a cool little trick for all you Cloudflare users out there. It’s possible to purge cache by customizing webhook payload.

1) Create a new webhook

2) Set URL method as DELETE and value as https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/purge_cache. You can find the Zone ID in the Overview page of your site in Cloudflare.

3) Set triggers and filters.

4) Add customer headers X-Auth-Email and X-Auth-Key. The values are your Cloudflare account e-mail and main API key, which can be found in My Profile --> API Keys.

5) Set Content type as application/json.

6) Check Automatically compute the value of the Content-Length header.

7) Select Customize the webhook payload and set the following payload:

{
  "purge_everything": true
}

PS: I wouldn’t mind if Contentful adds this as built-in feature. :slight_smile:

Thanks so much for sharing @teemu.tammela1!