-
Notifications
You must be signed in to change notification settings - Fork 41
HTTP Cache API #1051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
HTTP Cache API #1051
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3f13d65 to
f78e621
Compare
f78e621 to
aa85eaf
Compare
d663577 to
d691bf5
Compare
d691bf5 to
ab7846e
Compare
1df917e to
39159e7
Compare
e993c64 to
ed4e25f
Compare
56b48a9 to
468d807
Compare
96e00b5 to
af88dc9
Compare
2ee8d59 to
9f4d6ae
Compare
3d0ab54 to
74fb5a2
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 implements the HTTP Cache API following the Rust implementation very closely, it is almost a verbatim translation of the Rust SDK semantics, apart from being adapted to the JS fetch API and using async send calls.
This feature uses the HTTP cache APIs only when they are both supported and also when adding the
--enable-http-cacheCLI argument to the js-compute runtime build command. The plan is to disable this flag for future versions and make it the default, but we want to be careful to ensure adequate testing and to avoid regressions.Typing uses a variation of #1018 that uses real mutable Request and Response objects instead of relying on a new CandidateResponse object. The Response is effectively a CandidateResponse when it has a CacheEntry handle associated with it. A new error is then thrown when attempting to access the body of one of these response objects to support the CandidateResponse semantics. Effectively the CacheHandle slot being set handles the divergence here.
In the process, we also update
new CacheControl('override', { ... opts ... })to have the new direct override object syntax variationnew CacheControl({ ...opts... })as the override, and we also now support passing just the cache override init options to thecacheOverridefetch option, e.g. likefetch(url, { cacheOverride: { beforeSend () {...} } }).The
fetchimplementation is upgraded to usesend_async_v2and the new implementation is very closely based to the Rust implementation which should replicate the former caching logic in its entirety making this mostly a backwards compatible change, pending further testing before unflagging.Support for the
fetchcacheoption is not implemented here although could now be partially implemented as per #1050, which is effectively unblocked by this landing.