The deliveryType
read-only property is a string indicating how the resource was delivered — for example from the cache or from a navigational prefetch.
A string, which can be one of the following values:
"cache"
-
The resource was retrieved from the cache.
"navigational-prefetch"
-
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.
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.
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.
const scripts = performance.getEntriesByType("resource").filter((entry) => {
return entry.deliveryType === "cache";
});
console.log(scripts);