jorisnoo/craft-cdn-asset-purge

Purge CDN URLs when Craft CMS assets are replaced, renamed, moved, or deleted.

Maintainers

Package info

github.com/jorisnoo/craft-cdn-asset-purge

pkg:composer/jorisnoo/craft-cdn-asset-purge

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.1 2026-05-15 16:30 UTC

This package is auto-updated.

Last update: 2026-05-15 16:30:38 UTC


README

A Craft CMS module that purges CDN URLs when assets are replaced, renamed, moved, or deleted. Works with Bunny CDN or any other CDN that has a purge API.

Requirements

  • Craft CMS 5.0+
  • PHP 8.2+

Installation

Install via Composer:

composer require jorisnoo/craft-cdn-asset-purge

Register the module in config/app.php:

return [
    'modules' => [
        'cdn-asset-purge' => \Noo\CraftCdnAssetPurge\CdnAssetPurge::class,
    ],
    'bootstrap' => ['cdn-asset-purge'],
];

Configuration

Create config/cdn-asset-purge.php:

<?php

use craft\helpers\App;

return [
    'apiKey' => App::env('CDN_API_KEY'),
    'filesystems' => ['images'],
];
Setting Description Default
apiUrl The CDN purge API endpoint https://api.bunny.net/purge
apiKey Your CDN API key
authType Auth header style: access_key or bearer access_key
filesystems Filesystem handles to monitor []

Using a custom CDN

Override the API URL and auth type to point at any purge endpoint:

return [
    'apiUrl' => 'https://cdn.example.com/api/cache/purge',
    'apiKey' => App::env('CDN_API_KEY'),
    'authType' => 'bearer',
    'filesystems' => ['images'],
];

How it works

When an asset in a monitored volume is replaced, renamed, moved, or deleted, the module pushes a queue job that sends a purge request to the configured API endpoint. The purge happens asynchronously so it doesn't block the control panel.

License

MIT