Skip to main content
The CDN caches your files at edge locations around the world. Every upload goes to a new folder, so it has a new URL, and visitors never see an old cached copy of a replaced file. A deleted file is different: the edge can still serve its cached copy until the cache expires. purge tells Bunny to invalidate the cached copy right after a file is deleted. The plugin does not purge after an upload, because the URL of a new upload is not in the cache yet. A file is deleted when you delete a document, and when Payload removes a file that no document or version uses any more. See Files, versions and rename.
payload.config.ts

Options

Pass purge: true for defaults, purge: false to disable, or an object to customize:
The plugin purges the plain CDN URL of the file with a trailing *, so Bunny also clears cached copies with query strings, such as signed or transformed URLs.

Requirements

Cache purging is an account-level operation, so it needs a Bunny account API key (not the Storage or Stream key) at the top level, as accountApiKey. Get it from your Bunny dashboard → account menu (top-right) → Account settings → API → copy the API key.
Without a global accountApiKey, the options validator throws a startup error, including when only individual collections enable purge.Purging is only performed for Bunny Storage files — it doesn’t apply to Stream videos, which are served from Bunny’s video CDN and cached differently.

Alternative: timestamp-based cache busting

If you don’t want to manage an account API key, urlTransform.appendTimestamp or thumbnail.urlTransform.appendTimestamp add a changing query parameter to URLs instead. This is simpler to set up, but only busts the cache for browsers that re-fetch the URL — it doesn’t proactively clear Bunny’s edge cache.

Collection overrides

purge: true on a collection uses the global purge settings. See Collection overrides for the full list of options you can tune per collection.