# I make a Bunny CDN Perma Cache Auto Clearer Webhook

**URL:** <https://forum.ghost.org/t/i-make-a-bunny-cdn-perma-cache-auto-clearer-webhook/48324>\
**Category:** Integrations & API\
**Created:** [June 22, 2024, 6:43am UTC](https://forum.ghost.org/t/i-make-a-bunny-cdn-perma-cache-auto-clearer-webhook/48324 "2024-06-22T06:43:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![FanyangMeng](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/fanyangmeng/32/25998_2.png) [@FanyangMeng](https://forum.ghost.org/u/FanyangMeng)\
**Post date:** [June 22, 2024, 6:43am UTC](https://forum.ghost.org/t/i-make-a-bunny-cdn-perma-cache-auto-clearer-webhook/48324/1 "2024-06-22T06:43:08Z")

</div>

This can be easily integrate to the Ghost blog for people who is using Bunny CDN as their CDN.

Source Code: [Github Repo](https://github.com/MFYDev/bunnycdn-perma-cache-clearer)

## Motivation

According to the [Bunny CDN official documentation](https://support.bunny.net/hc/en-us/articles/8048968124828-Integrating-Perma-Cache-with-your-site), in a full pull zone purge complete purge, the Perma-Cache retains the files but shifts to a new directory structure within the storage zone. If needed, you must manually delete the old cache folder.

**Perma-Cache is expensive, and sometimes you could easily forgot to clear the old cache folder, which will make them take tons of space which will cost your money.**

That’s why I make this webhook so that you can easily integrate to your website to automatically clear the old cache folder whenever you want to trigger it.

## Features

- Immediate cache clearing upon a POST request.
- Scheduled cache clearing at intervals of 1 minute and 3 minutes.
- Logging of cache clearing activities and thread status.
- Thread-safe execution using locks to prevent concurrent cache clearing.

## Contributing

Contributions are welcome! Please open an issue or submit a pull request for any changes or enhancements.
