BunnyCDN Perma-Cache Purger for Docker

… yes, even more BunnyCDN content! :tada:

Over the past few weeks, I’ve been diving deep into integrating Bunny.net’s CDN into Magic Pages’s hosting. The previous CDN setup—using a storage adapter—wasn’t quite cutting it.

BunnyCDN is fantastic—it’s easy to set up with Ghost, but getting everything just right isn’t trivial.

One challenge was dealing with Perma-Cache. Without it, performance improved, but it still wasn’t on par with Ghost(Pro)'s Fastly network. However, enabling Perma-Cache set the cache duration to one year—way too long for anyone updating their Ghost blog regularly.

Then, a few weeks ago, I stumbled upon this old issue on GitHub—and almost 11 years later, I was thrilled to see that the X-Cache-Invalidate header is still in play :tada:

That discovery sparked an idea: why not create something that monitors this header and triggers a cache invalidation API call to BunnyCDN? But because of some other priorities, I put it on a back burner.

Then, after seeing @FanyangMeng’s recent post, I kept thinking about it, and came up with a solution that seamlessly integrates into the Magic Pages’s stack. And because sharing is caring, here it is:

Long story short: If you’re running Ghost in Docker, integrating this Perma-Cache purger will literally just take a few seconds—provided you have BunnyCDN set up.

Eager to hear your feedback and thoughts on this integration!

Congrats on this awesome project! I am gonna take a look! Although I am using local install for my own ghost but migrating the database to docker should not be that hard if I need to use it. I am gonna learn about your code a bit, cannot believe you made it!!!

1 Like

Haha just a few lines of Express.js, nothing magical, to be honest.

You should be able to run it without Docker as well, since it’s just a single-file Node.js script. Just haven’t tested that myself :smiley: