feat: use Deno KV for storing fresh assets #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds esbuild assets to Deno KV. This feature uses Deno KV as an optimization and KV is not required for serving assets on both dev and production environments.
How does it work?
All isolate instances have an internal inMemory cache. We use the following algorithm for incoming requests:
With this algorithm, we ensure:
2
is nice because it should remove issues of missing assets when any chunk changes due to esm.sh changesConsistency
store assets in kv in background
means:Streaming
A nice approach to saving assets in KV in 64Kb chunks is that we are able to stream these chunks when serving assets from KV
Debug
Since this is a difficult feature to get right, I'm adding a bunch of console.logs that may be removed in the future. To make your life more pleasant, I added emojis! 🎉
I hope to make this PR a fresh PR one day.