You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it's worth a shot trying out Cloudflare KV for directory listings in an effort to lower uncached response times.
How it could work
The R2Provider's listDirectory works by just rewriting to the S3Provider (src). I think we can add a KVProvider that just serves directory listings, similar to the S3Provider, and just use it there instead.
I do think we should keep the S3Provider just for extra redundancy in case there's some issue with KV or the KV provider.
The data in KV
The key would be the directory's path in R2 (i.e. nodejs/release/v20.0.0).
The value would be a stringified JSON array with the directory's contents (i.e. ['docs/', 'node.exe']).
How we get the directory listings into KV
Option A
Upon release promotion, purge the KV namespace. Then, list the entire bucket directory by directory and add them to the KV namespace. If a directory isn't present in KV, treat it like it doesn't exist and send a 404. We might be able to figure out something smart to only purge the effected directories, but it's not necessary.
Option B
Use KV like a cache. We'll check if a path exists in KV, if it doesn't then we'll fall back to the S3 provider and add the result to the KV namespace. We will need to invalidate all of the paths upon a new release getting promoted (again, we might be able to figure out something smart to only purge the effected directories).
(I would prefer option A since it also works for unknown directories and it's implementation should be simpler).
I'm not sure how much space this would take up (I made some rough estimations of ~5mb in an earlier issue, can't seem to find it however and it was a different structure).
We would probably exceed the limit of 10 million reads free reads a month, however.
The text was updated successfully, but these errors were encountered:
I think it's worth a shot trying out Cloudflare KV for directory listings in an effort to lower uncached response times.
How it could work
The
R2Provider
'slistDirectory
works by just rewriting to theS3Provider
(src). I think we can add aKVProvider
that just serves directory listings, similar to the S3Provider, and just use it there instead.I do think we should keep the
S3Provider
just for extra redundancy in case there's some issue with KV or the KV provider.The data in KV
The key would be the directory's path in R2 (i.e.
nodejs/release/v20.0.0
).The value would be a stringified JSON array with the directory's contents (i.e.
['docs/', 'node.exe']
).How we get the directory listings into KV
Option A
Upon release promotion, purge the KV namespace. Then, list the entire bucket directory by directory and add them to the KV namespace. If a directory isn't present in KV, treat it like it doesn't exist and send a 404. We might be able to figure out something smart to only purge the effected directories, but it's not necessary.
Option B
Use KV like a cache. We'll check if a path exists in KV, if it doesn't then we'll fall back to the S3 provider and add the result to the KV namespace. We will need to invalidate all of the paths upon a new release getting promoted (again, we might be able to figure out something smart to only purge the effected directories).
(I would prefer option A since it also works for unknown directories and it's implementation should be simpler).
Pricing
I'm not sure how much space this would take up (I made some rough estimations of ~5mb in an earlier issue, can't seem to find it however and it was a different structure).
We would probably exceed the limit of 10 million reads free reads a month, however.
The text was updated successfully, but these errors were encountered: