You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -28,6 +30,7 @@ Built on top of `@payloadcms/plugin-cloud-storage` for easy integration with Pay
28
30
- Handle videos with Bunny Stream (HLS, MP4, thumbnails)
29
31
- Show thumbnails in your admin panel
30
32
- Control access via Payload or direct CDN links
33
+
- Automatic CDN cache purging for updated files
31
34
32
35
## ⚡ Performance Recommendation
33
36
@@ -157,6 +160,29 @@ stream: {
157
160
158
161
**Important**: Video support is always available, even without Bunny Stream configured. If Bunny Stream is disabled, video files will simply be uploaded to Bunny Storage like any other file type. Bunny Stream just provides enhanced video features (streaming, adaptive bitrates, thumbnails).
159
162
163
+
### Cache Purging Configuration
164
+
165
+
Enable automatic CDN cache purging for storage files (not applicable to Stream):
166
+
167
+
```typescript
168
+
purge: {
169
+
// Enable cache purging
170
+
enabled: true,
171
+
172
+
// Your Bunny API key
173
+
apiKey: string,
174
+
175
+
// Optional: wait for purge to complete (default: false)
176
+
async?:boolean
177
+
}
178
+
```
179
+
180
+
When enabled, the plugin will automatically purge the CDN cache after:
181
+
- File uploads
182
+
- File deletions
183
+
184
+
This ensures that visitors always see the most up-to-date version of your files, which is especially important when replacing existing files (e.g., during image cropping operations).
185
+
160
186
### Admin Thumbnail Configuration
161
187
162
188
Control thumbnails in your admin panel:
@@ -177,6 +203,8 @@ adminThumbnail: {
177
203
}
178
204
```
179
205
206
+
When `appendTimestamp` is enabled (or using the default setting), the plugin automatically adds a timestamp parameter to image URLs in the admin panel. This ensures that when files are updated, the admin UI always shows the latest version without browser caching issues.
207
+
180
208
The `queryParams` option is particularly useful when used with Bunny's Image Optimizer service, allowing you to resize, crop, and optimize images on-the-fly.
181
209
182
210
### Access Control Configuration
@@ -207,6 +235,47 @@ When `disablePayloadAccessControl: true`:
207
235
- Faster delivery but open access
208
236
- No need for MP4 fallback
209
237
238
+
## CDN Cache Management
239
+
240
+
There are two approaches to managing the CDN cache for your Bunny Storage files:
241
+
242
+
### Option 1: Automatic Cache Purging
243
+
244
+
You can enable automatic cache purging whenever files are uploaded or deleted:
245
+
246
+
```typescript
247
+
purge: {
248
+
enabled: true,
249
+
apiKey: process.env.BUNNY_API_KEY,
250
+
async: false// Wait for purge to complete (default: false)
251
+
}
252
+
```
253
+
254
+
This is the most comprehensive approach as it ensures the CDN cache is immediately purged when files change, making the updated content available to all visitors.
255
+
256
+
### Option 2: Timestamp-Based Cache Busting
257
+
258
+
For the admin panel specifically, you can use timestamp-based cache busting:
259
+
260
+
1. First, configure the plugin to add timestamps to image URLs:
261
+
262
+
```typescript
263
+
adminThumbnail: {
264
+
appendTimestamp: true
265
+
}
266
+
```
267
+
268
+
2. In your Bunny Pull Zone settings:
269
+
- Go to the "Caching" section
270
+
- Enable "Vary Cache" for "URL Query String"
271
+
- Add "t" to the "Query String Vary Parameters" list
272
+
273
+
This approach only affects how images are displayed in the admin panel and doesn't purge the actual CDN cache. It appends a timestamp parameter (`?t=1234567890`) to image URLs, causing Bunny CDN to treat each timestamped URL as a unique cache entry.
274
+
275
+
Choose the approach that best fits your needs:
276
+
- Use **automatic cache purging** for immediate updates everywhere
277
+
- Use **timestamp-based cache busting** for a simpler setup that only affects the admin panel
278
+
210
279
## Getting API Keys
211
280
212
281
### Bunny Storage API Key
@@ -233,6 +302,16 @@ To find your Bunny Stream API key:
233
302
5. Find "CDN Hostname" for your `hostname` setting (like "vz-example-123.b-cdn.net")
234
303
6. The "API Key" is found at the bottom of the page
235
304
305
+
### Bunny API Key
306
+
307
+
To find your Bunny API key (used for cache purging):
308
+
309
+
1. Go to your Bunny.net dashboard
310
+
2. Click on your account in the top-right corner
311
+
3. Select "Account settings" from the dropdown menu
312
+
4. Click on "API" in the sidebar menu
313
+
5. Copy the API key displayed on the page
314
+
236
315
## Storage Regions
237
316
238
317
Choose where to store your files. If you don't pick a region, the default storage location is used.
@@ -281,6 +360,28 @@ bunnyStorage({
281
360
})
282
361
```
283
362
363
+
### With Cache Purging Enabled
364
+
365
+
```typescript
366
+
bunnyStorage({
367
+
collections: {
368
+
media: true,
369
+
},
370
+
options: {
371
+
storage: {
372
+
apiKey: process.env.BUNNY_STORAGE_API_KEY,
373
+
hostname: 'storage.example.b-cdn.net',
374
+
zoneName: 'my-zone',
375
+
},
376
+
purge: {
377
+
enabled: true,
378
+
apiKey: process.env.BUNNY_API_KEY,
379
+
async: false, // Wait for purge to complete
380
+
},
381
+
},
382
+
})
383
+
```
384
+
284
385
### With Bunny Stream & Direct CDN Access
285
386
286
387
```typescript
@@ -304,6 +405,10 @@ bunnyStorage({
304
405
libraryId: '123456',
305
406
thumbnailTime: 5000, // 5 seconds in milliseconds
306
407
},
408
+
purge: {
409
+
enabled: true,
410
+
apiKey: process.env.BUNNY_API_KEY,
411
+
},
307
412
},
308
413
})
309
414
```
@@ -332,6 +437,10 @@ bunnyStorage({
332
437
mp4Fallback: { enabled: true }, // Required with access control
0 commit comments