Tools: Why I Built a Self-Hosted Cloudflare Cache Purger for Ghost

Tools: Why I Built a Self-Hosted Cloudflare Cache Purger for Ghost

I recently started caching the public HTML pages of my self-hosted Ghost blog with Cloudflare. That made the site faster, but it also created a small freshness problem: after publishing or updating a post, some pages can stay cached for longer than I want. The simple solution is to let Ghost send a webhook whenever a post changes. My cache purger receives that webhook, verifies it, checks what changed, and then asks Cloudflare to purge the relevant cached URLs. The flow looks like this: While looking into this, I also found this blog about using a Cloudflare Worker for Ghost cache purging: https://www.paolotagliaferri.com/cloudflare-cache-purge-with-ghost-webhook/ That removes the need for an extra container, but the Worker still needs code to handle the webhook and call the Cloudflare API. I chose a self-hosted Docker container because I like keeping this kind of automation inside my own stack. It is easy to inspect with Docker logs, it fits naturally next to my Ghost container, and it gives me more flexibility to do custom things with Ghost webhook events later. Right now it purges cache, but the same webhook service could eventually do more interesting things with Ghost events. For example, it could log post updates, send notifications, track new members, trigger other automations, or handle custom rules based on the webhook payload. That is what I like about self-hosting small tools like this. It starts as one practical fix, but it can grow into a small automation layer around the rest of the setup. I am not claiming this is the only or best way to handle Ghost cache purging. I just liked building a Docker-based version that fits naturally into a self-hosted Ghost environment. I wrote the full explanation here: https://zerotohomelab.cloudboxhub.com/how-i-automated-cloudflare-cache-purging-for-my-self-hosted-ghost-blog/ You can use the code as-is, or modify it to fit your own setup. The nice thing about keeping it small is that it is easy to customize: you can change the purge logic, add extra webhook handling, or use it as a starting point for your own Ghost automation service. The code and Docker image are also available directly: Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Code Block

Copy

Ghost webhook → self-hosted cache purger → Cloudflare API Ghost webhook → self-hosted cache purger → Cloudflare API Ghost webhook → self-hosted cache purger → Cloudflare API - GitHub: https://github.com/Marin1999/cloudflare-purger - Docker Hub: https://hub.docker.com/r/marink1999/ghost-cloudflare-cache-purger