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
Copy file name to clipboardExpand all lines: src/content/docs/workers/testing/miniflare/storage/cache.md
+15Lines changed: 15 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -81,6 +81,21 @@ res = await mf.dispatchFetch("http://localhost:8787");
81
81
console.log(awaitres.text()); // 2
82
82
```
83
83
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
+
constmf=newMiniflare({ /* options */ });
90
+
91
+
// Purge the default cache and get the number of entries purged
92
+
constcount=awaitmf.purgeCache();
93
+
console.log(`Purged ${count} entries`);
94
+
95
+
// Purge a specific named cache
96
+
awaitmf.purgeCache("my-named-cache");
97
+
```
98
+
84
99
## Disabling
85
100
86
101
Both default and named caches can be disabled with the `disableCache` option.
0 commit comments