in workbox-v4.3.1/workbox-strategies.dev.js [116:187]
async makeRequest({
event,
request
}) {
const logs = [];
if (typeof request === 'string') {
request = new Request(request);
}
{
assert_mjs.assert.isInstance(request, Request, {
moduleName: 'workbox-strategies',
className: 'CacheFirst',
funcName: 'makeRequest',
paramName: 'request'
});
}
let response = await cacheWrapper_mjs.cacheWrapper.match({
cacheName: this._cacheName,
request,
event,
matchOptions: this._matchOptions,
plugins: this._plugins
});
let error;
if (!response) {
{
logs.push(`No response found in the '${this._cacheName}' cache. ` + `Will respond with a network request.`);
}
try {
response = await this._getFromNetwork(request, event);
} catch (err) {
error = err;
}
{
if (response) {
logs.push(`Got response from network.`);
} else {
logs.push(`Unable to get a response from the network.`);
}
}
} else {
{
logs.push(`Found a cached response in the '${this._cacheName}' cache.`);
}
}
{
logger_mjs.logger.groupCollapsed(messages.strategyStart('CacheFirst', request));
for (let log of logs) {
logger_mjs.logger.log(log);
}
messages.printFinalResponse(response);
logger_mjs.logger.groupEnd();
}
if (!response) {
throw new WorkboxError_mjs.WorkboxError('no-response', {
url: request.url,
error
});
}
return response;
}