Skip to content

feat(storage): add purgeProjectCache to purge the CDN cache of every bucket - #2860

Open
officialasishkumar wants to merge 1 commit into
supabase:masterfrom
officialasishkumar:feat/storage-purge-project-cache
Open

officialasishkumar wants to merge 1 commit into
supabase:masterfrom
officialasishkumar:feat/storage-purge-project-cache

Conversation

@officialasishkumar

Copy link
Copy Markdown

🔍 Description

What changed?

Adds purgeProjectCache(options?, parameters?) to the Storage bucket API, so supabase.storage.purgeProjectCache() invalidates the CDN cache for every bucket in the project. It maps to the Storage API's DELETE /cdn/ endpoint.

It works the same way as the existing purgeBucketCache and from(bucket).purgeCache:

  • { transformations: true } purges only resized/formatted variants and keeps the cached originals (?transformations=true)
  • an AbortSignal can be passed through parameters
  • it returns { data: { message }, error: null }, or { data: null, error: StorageError }

It also registers storage.file_buckets.purge_project_cache in sdk-compliance.yaml (the capability already exists in the pinned capability matrix) and widens the PurgeCacheOptions.transformations doc to cover project-wide purges.

Why was this change needed?

The Storage API exposes three purge scopes: project, bucket and object. supabase-js covers only bucket and object (#2429). Purging the whole project, for example after changing image transformation settings, meant listing every bucket and calling purgeBucketCache on each one. The capability matrix tracks the project scope as storage.file_buckets.purge_project_cache, which supabase-js has not implemented yet.

📸 Screenshots/Examples

// Purge the CDN cache for every bucket in the project
const { data, error } = await supabase.storage.purgeProjectCache()

// Purge only transformed variants across the project
const { data, error } = await supabase.storage.purgeProjectCache({ transformations: true })

🔄 Breaking changes

  • This PR contains no breaking changes

📋 Checklist

  • I have read the Contributing Guidelines
  • My PR title follows the conventional commit format: <type>(<scope>): <description>
  • I have run pnpm nx format to ensure consistent code formatting
  • I have added tests for new functionality (if applicable)
  • I have updated documentation (if applicable)

📝 Additional notes

  • The request path is /cdn/ with a trailing slash. That's the exact path the Storage server registers and tests for the tenant purge route (src/http/routes/cdn/purgeCache.ts, src/test/cdn.test.ts in supabase/storage).
  • The new unit tests in storageBucketApi.test.ts mirror the purgeBucketCache ones: URL, transformations query, signal forwarding, and error mapping.
  • I ran the SDK compliance tooling at the pinned SHA locally. validate-compliance and check-api-symbols both pass. The additions check also needs the inherited StorageClient.purgeProjectCache registered, so it is listed next to default.purgeProjectCache.

…bucket

Storage already exposes `purgeBucketCache(bucket)` and
`from(bucket).purgeCache(path)`, but not the project-wide
`DELETE /cdn/` endpoint, so invalidating the CDN cache of the whole
project meant purging bucket by bucket.

Add `purgeProjectCache(options?, parameters?)` on the bucket API
(`supabase.storage.purgeProjectCache()`). Like the other purge methods
it accepts `{ transformations: true }` to purge only resized/formatted
variants, forwards an `AbortSignal`, and returns `{ data: { message } }`
or a `StorageError`.

Register `storage.file_buckets.purge_project_cache` in
sdk-compliance.yaml and cover the request URL, query string, signal
forwarding and error mapping with unit tests.
@officialasishkumar
officialasishkumar requested review from a team as code owners November 14, 2026 11:48
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • Added an option to purge cached content across a project, with the ability to target transformation results while leaving original cached files intact.
    • Project-wide cache purges require appropriate permissions and hosted CDN configuration.
  • Documentation
    • Clarified that transformation-only purges can target an object, bucket, or project.

StorageBucketApi adds purgeProjectCache to send a DELETE request to /cdn/. The method supports optional transformation purging and fetch parameters. Tests cover successful and error responses, the transformation query parameter, and abort-signal forwarding. The SDK compliance file marks the capability as implemented.

Change: Feature

Merge Risk: Minimal · up to fd301

This adds a project-wide CDN cache purge method to the storage client. It is additive and covered by unit tests, so there is no identified merge-blocking risk.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: df6664a8-1e30-4234-86b1-eedb6f0eaf09
Commits

Reviewing files that changed from the base of the PR and between 13211d9 and fd30193.

Files selected for processing: 4

  • packages/core/storage-js/src/lib/types.ts
  • packages/core/storage-js/src/packages/StorageBucketApi.ts
  • packages/core/storage-js/test/storageBucketApi.test.ts
  • sdk-compliance.yaml

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant