INNER CODE UNIT · JavaScript
getItemFromCacheOrWeb
mozilla/firefox-translations · extension/controller/backgroundScript.js:746
const getItemFromCacheOrWeb = async (tabId, itemURL, fileSize, fileChecksum) => {
let buffer = null;
/*
* there are two possible sources for the translation modules: the Cache
* API or the network. We check for their existence in the
* former, and if it's not there, we download from the network and
* save it in the cache.
*/
try {
const cache = await caches.open(CACHE_NAME);
let response = await cache.match(itemURL);
if (!response) {
/*
* no match for this object was found in the cache.
* we'll need to download it and inform the progress to the
* sender UI so it could display it to the user