11cb0ef41Sopenharmony_ci# CacheStorage
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciUndici exposes a W3C spec-compliant implementation of [CacheStorage](https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage) and [Cache](https://developer.mozilla.org/en-US/docs/Web/API/Cache).
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci## Opening a Cache
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciUndici exports a top-level CacheStorage instance. You can open a new Cache, or duplicate a Cache with an existing name, by using `CacheStorage.prototype.open`. If you open a Cache with the same name as an already-existing Cache, its list of cached Responses will be shared between both instances.
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci```mjs
101cb0ef41Sopenharmony_ciimport { caches } from 'undici'
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciconst cache_1 = await caches.open('v1')
131cb0ef41Sopenharmony_ciconst cache_2 = await caches.open('v1')
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci// Although .open() creates a new instance,
161cb0ef41Sopenharmony_ciassert(cache_1 !== cache_2)
171cb0ef41Sopenharmony_ci// The same Response is matched in both.
181cb0ef41Sopenharmony_ciassert.deepStrictEqual(await cache_1.match('/req'), await cache_2.match('/req'))
191cb0ef41Sopenharmony_ci```
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci## Deleting a Cache
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ciIf a Cache is deleted, the cached Responses/Requests can still be used.
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ci```mjs
261cb0ef41Sopenharmony_ciconst response = await cache_1.match('/req')
271cb0ef41Sopenharmony_ciawait caches.delete('v1')
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ciawait response.text() // the Response's body
301cb0ef41Sopenharmony_ci```
31