Can you purge everything from a custom cache instance?

When accessing Cache from a Worker, the docs say we "may create and manage additional Cache instances via the caches.open method." https://developers.cloudflare.com/workers/runtime-apis/cache/#accessing-cache Is there a simple way to purge everything in a custom cache instance?
Cache · Cloudflare Workers docs
The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
1 Reply
ale
ale•12mo ago
Hey Jordan 👋 , Unless you use Cache Tags or Purge Everything (assuming you are using custom domain for your Worker), not really. If you have an Enterprise account, you can add a Cache Tag to the responses served by a specific cache instance and then use this as a key when deciding what to purge. The other option would be to Purge Everything in your zone but I know that it might be a bit of an stretch. You may also consider using cache.delete to purge individual keys from these instances (which I wouldn't expect to have more than one key per instance). The only caveat is that deletes are performed locally at each datacenter so to fully complete the purge of an asset globally, you might need to first delete the keys in the instance (or override it) before continuing with the request. I didn't see any use case so far where a cache instance had more than one value, so performing a delete/override before continuing with the normal execution of the script might be a workaround if Cache Tags are not available in your account. https://developers.cloudflare.com/workers/learning/how-the-cache-works/#purging-assets-stored-with-the-cache-api
How the Cache works · Cloudflare Workers docs
Workers was designed and built on top of Cloudflare’s global network to allow developers to interact directly with the Cloudflare cache. The cache can …