W3cubDocs

/Web APIs

PerformanceResourceTiming: deliveryType property

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The deliveryType read-only property is a string indicating how the resource was delivered — for example from the cache or from a navigational prefetch.

Value

A string, which can be one of the following values:

"cache"

The resource was retrieved from the cache.

The resource was retrieved from a prefetched response stored in an in-memory cache via the Speculation Rules API.

"" (empty string)

Returned if none of the above delivery types apply.

Examples

Filtering resources

The deliveryType property can be used to get specific resource timing entries only; for example, only those that were cached.

The following example uses a PerformanceObserver to notify of new resource performance entries as they are recorded in the browser's performance timeline. The buffered option is used for accessing entries from before the observer creation.

js

const observer = new PerformanceObserver((list) => {
  const cachedResources = list.getEntries().filter((entry) => {
    return entry.deliveryType === "cache";
  });
  console.log(cachedResources);
});

observer.observe({ type: "resource", buffered: true });

The following example uses Performance.getEntriesByType(), which only shows resource performance entries present in the browser's performance timeline at the time you call the method.

js

const scripts = performance.getEntriesByType("resource").filter((entry) => {
  return entry.deliveryType === "cache";
});
console.log(scripts);

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
deliveryType 117 117 No No 103 No 117 117 No No No No
navigational-prefetch 117 117 No No 103 No 117 117 No No No No

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/deliveryType