Alex-At-Home / cbb-on-off-analyzer

A not-so-simple-any-more! SPA for rendering college basketball on/off analysis
https://cbb-on-off-analyzer.now.sh
Apache License 2.0
0 stars 2 forks source link

Static files are getting close to the 5MB serve limit #200

Closed Alex-At-Home closed 1 year ago

Alex-At-Home commented 2 years ago

2021/22 players Low tier got that high

Options:

Alex-At-Home commented 2 years ago

Note that I believe every request to the player leaderboard if any of them are >5MB costs me GCS transfer monies also

Maybe add a line to the ingest pipeline to not transfer any files that are >=5MB?

Alex-At-Home commented 2 years ago

Couldn't immediately get the direct gz working

            const respBlob = await resp.blob();
            const respBinaryArray = await respBlob.arrayBuffer();
/**/
console.log(respBinaryArray.byteLength);            
            //const respJson = await resp.json();
            res.setHeader("Content-Encoding", "gz");
            res.setHeader("Content-Type", "application/json");
            res.setHeader("Cache-Control", "s-maxage=28800"); // requests that the CDN cache this for 12 hours or until the app redeploys
//            res.status(200).json(respJson);
            res.status(200).send(Buffer.from(respBinaryArray));

Returned and send a binary object but wasn't able to decode it as JSON

Alex-At-Home commented 2 years ago

Ah GCS also caches the data for an hour, which isn't ideal

Options:

Alex-At-Home commented 2 years ago

For now I added cacheId=${process.Env.VERCEL_URL} which I think but haven't confirmed will update on each redeploy (but otherwise should give 1 hr)

Alex-At-Home commented 1 year ago

Ended up getting compression working