Skip to content

Commit c930838

Browse files
Add purgeCache docs to miniflare cache page (#28172)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent c71f206 commit c930838

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

  • src/content/docs/workers/testing/miniflare/storage

src/content/docs/workers/testing/miniflare/storage/cache.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,21 @@ res = await mf.dispatchFetch("http://localhost:8787");
8181
console.log(await res.text()); // 2
8282
```
8383

84+
## Purging
85+
86+
You can programmatically purge all entries from a cache using the `purgeCache` method on the `Miniflare` instance. This is useful during development when cached assets need to be cleared without restarting the instance:
87+
88+
```js
89+
const mf = new Miniflare({ /* options */ });
90+
91+
// Purge the default cache and get the number of entries purged
92+
const count = await mf.purgeCache();
93+
console.log(`Purged ${count} entries`);
94+
95+
// Purge a specific named cache
96+
await mf.purgeCache("my-named-cache");
97+
```
98+
8499
## Disabling
85100

86101
Both default and named caches can be disabled with the `disableCache` option.

0 commit comments

Comments
 (0)