MCPcopy Index your code
hub / github.com/angular/angular / fetchFromCacheOnly

Function fetchFromCacheOnly

packages/service-worker/worker/src/assets.ts:258–280  ·  view source on GitHub ↗

* Fetch the complete state of a cached resource, or return null if it's not found.

(url: string)

Source from the content-addressed store, hash-verified

256 * Fetch the complete state of a cached resource, or return null if it's not found.
257 */
258 async fetchFromCacheOnly(url: string): Promise<CacheState | null> {
259 const cache = await this.cache;
260 const metaTable = await this.metadata;
261
262 // Lookup the response in the cache.
263 const request = this.adapter.newRequest(url);
264 const response = await cache.match(request, this.config.cacheQueryOptions);
265 if (response === undefined) {
266 // It's not found, return null.
267 return null;
268 }
269
270 // Next, lookup the cached metadata.
271 let metadata: UrlMetadata | undefined = undefined;
272 try {
273 metadata = await metaTable.read<UrlMetadata>(request.url);
274 } catch {
275 // Do nothing, not found. This shouldn't happen, but it can be handled.
276 }
277
278 // Return both the response and any available metadata.
279 return {response, metadata};
280 }
281
282 /**
283 * Lookup all resources currently stored in the cache which have no associated hash.

Callers

nothing calls this directly

Calls 2

newRequestMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…