Find answers, guides, and tutorials to supercharge your content delivery.

Using GitHub Webhooks to Purge Cache

Updated on October 4, 2018
Using GitHub Webhooks to Purge Cache

Let's say you're working on a web project and are making commits through GitHub that will update its look or functionality. If you're using a CDN such as KeyCDN, then you'll need to either purge the assets you've updated or purge the entire Zone so that all visitors will receive the latest asset changes. This can be a slightly cumbersome process if you're required to log in to your KeyCDN dashboard every time you need to purge an asset URL or Zone.

However, with GitHub Webhooks, you can instantly purge an entire Zone upon committing a change. This makes the purging process much more streamlined. What's more, this process is easy to setup and in this guide, we'll cover how to do just that.

Purging KeyCDN Zones with GitHub webhooks

Properly configuring a GitHub webhook is a simple task. Follow the steps below to implement this in your own workflow.

  1. Go to your repository's Settings page, then click on Webhooks:

  2. Select "Add Webhook" and configure the Payload URL to resemble the following (remember to add your KeyCDN API key and the Zone ID that you want to purge):

    https://<API key><zone id>.json

    Additionally, select application/json as the Content type:

  3. After committing a change to your repo, check that the Webhook ran successfully by navigating to the Webhook you just created and scrolling to the bottom of the page to "Recent Deliveries".

  4. Expand one of the recent deliveries and check the Response to ensure that the KeyCDN purge completed successfully.


Once your webhook is implemented, you'll be able to automatically purge a particular Zone whenever you commit a change to your GitHub repository. If ever you need to change the Zone being purged, simply edit the Webhook to include the new Zone ID or remove the Webhook if it is no longer needed. For more information about purging options with KeyCDN, check out our complete purge CDN cache article.

Supercharge your content delivery 🚀

Try KeyCDN with a free 14 day trial, no credit card required.

Get started
KeyCDN uses cookies to make its website easier to use. Learn more about cookies.