Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

118
Vistas
Concat blobs to store them in a single Cache entry, and then retrieve them

I need to download an heavy file from the network, this file is then processed client-side and it results in a list of File entities.

Right now I'm using the Cache API to make sure downloading the same file doesn't need to go through the network again, but this requires my code to always process the cached file locally to obtain the list of files.

I'd like, instead, to store in cache the output of the process operation so that subsequent accesses don't require to process the single file to generate the multiple output files.

The problem I'm having is that I need a way to concat multiple File (or Blob?) entities into a single Blob that can then be added to my cache.

Below is the code I'm using right now, which doesn't handle the caching of the processed file:

async function getFile(url) {
  const cache = await caches.open('V1');
  
  const cached = await caches.match(url);
  if (cached != null) {
    return cached;
  }

  const response = await fetch(url, {
    credentials: 'include',
  });

  if (!response.ok) {
    throw new TypeError('bad response status');
  }

  await cache.put(url, response);

  return cache.match(url);
}

const download = await getFile('https://example.org/big.tar.gz');
const downloadArrayBuffer = await download.arrayBuffer();

// I'd like the cache to contain the output of the following operation
const files = await untar(downloadArrayBuffer);
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda