@ -124,6 +124,7 @@ const cacheFirst = async ({ request, preloadResponsePromise, refreshAnyway }) =>
}
}
// Next try to use (and cache) the preloaded response, if it's there
// Next try to use (and cache) the preloaded response, if it's there
try {
if ( preloadResponsePromise ) {
if ( preloadResponsePromise ) {
const preloadResponse = await preloadResponsePromise
const preloadResponse = await preloadResponsePromise
if ( preloadResponse && preloadResponse . ok ) {
if ( preloadResponse && preloadResponse . ok ) {
@ -135,6 +136,11 @@ const cacheFirst = async ({ request, preloadResponsePromise, refreshAnyway }) =>
console . log ( '[cf] got not ok preloadResponse, ignoring' , preloadResponse )
console . log ( '[cf] got not ok preloadResponse, ignoring' , preloadResponse )
}
}
}
}
}
catch ( e ) {
// Ignore as preload isn't necessarily important
console . error ( '[cf] preload response error' , e )
}
// Next try to get the resource from the network
// Next try to get the resource from the network
const responseFromNetwork = await fetch ( request )
const responseFromNetwork = await fetch ( request )
@ -153,6 +159,7 @@ const cacheFirst = async ({ request, preloadResponsePromise, refreshAnyway }) =>
const networkFirst = async ( { request , preloadResponsePromise } ) => {
const networkFirst = async ( { request , preloadResponsePromise } ) => {
// First try to use (and cache) the preloaded response, if it's there
// First try to use (and cache) the preloaded response, if it's there
try {
if ( preloadResponsePromise ) {
if ( preloadResponsePromise ) {
const preloadResponse = await preloadResponsePromise
const preloadResponse = await preloadResponsePromise
if ( preloadResponse && preloadResponse . ok ) {
if ( preloadResponse && preloadResponse . ok ) {
@ -164,6 +171,11 @@ const networkFirst = async ({ request, preloadResponsePromise }) => {
console . log ( '[nf] got not ok preloadResponse, ignoring' , preloadResponse )
console . log ( '[nf] got not ok preloadResponse, ignoring' , preloadResponse )
}
}
}
}
}
catch ( e ) {
// Ignore as preload isn't necessarily important
console . error ( '[nf] preload response error' , e )
}
// Next try to get the resource from the network
// Next try to get the resource from the network
let responseFromNetwork
let responseFromNetwork