Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!