You don’t need to buffer the whole thing

You don’t need to buffer the whole thing in memory, you can stream directly from R2 into the Cache
7 Replies
jsonperl
jsonperl2w ago
Hmm, that's interesting. I didn't realize you could stream to the cache
Hard@Work
Hard@Work2w ago
Yep, the Cache API takes a Request to match against, and a Response to return
jsonperl
jsonperl2w ago
So do you think I'd manually cache the entire audio, and then on successive calls pull from cache, zoom to the right bits and deliver those?
Hard@Work
Hard@Work2w ago
Yeah. If you don't mind slightly higher pricing, you could issue two concurrent requests against R2, one for the entire file(which is then put to the cache asynchronously), and then another one for just the requested range
jsonperl
jsonperl2w ago
This is good stuff. Thanks, will poke around @Hello, I’m Allie! if I store the full audio in the cache, there's no way to issue a range request against the cache is there? I'll need to pull the whole thing and slice the bits myself?
Hard@Work
Hard@Work2w ago
No description
jsonperl
jsonperl6d ago
I really cannot for the life of me get the cache to response properly to a range request. It's always just returning the whole cached file.

Did you find this page helpful?