Comments (9)
I have somehow interest to implement it...
from undici.
I would start having an interceptor or Agent that implement the caching protocol of HTTP, and then worry about how we enable it all the time.
I think it's possible to have it always enabled and not cache any private data: that's how cdn works after all. Before worrying about this, we need the implementation ;).
from undici.
Ok, i will start tonight. ;)
from undici.
I've looked into implementing this as an interceptor, and need some information in order to proceed:
- Is there existing code for caching and cloning responses in the code base that can be used (for this I was expecting to be able to use logic from the web cache which seems to be implementing the Service Worker Spec)
- Is rfc7234 implemented anywhere in the codebase (I cannot find any indication that it is). http-cache-semantics seems to be a good reference implementation of it if not, however it is under the BSD-2-Clause so @kornelski would need to give permission in order for code to be re-used in this library without copying the BSD licence over.
from undici.
Is there existing code for caching and cloning responses in the code base that can be used (for this I was expecting to be able to use logic from the web cache which seems to be implementing the Service Worker Spec)
Can you elaborate on what you have in mind?
Is rfc7234 implemented anywhere in the codebase (I cannot find any indication that it is). http-cache-semantics seems to be a good reference implementation of it if not, however, it is under the BSD-2-Clause so @kornelski would need to permit for code to be re-used in this library without copying the BSD licence over.
The closest implementation will be the fetch
one but I don't believe it implements its full RFC-7234 spec, so this will be a new implementation for the interceptor.
from undici.
Can you elaborate on what you have in mind?
I was trying to work out the easiest way of caching the response object in-memory would be given that I'm assuming it would be coming through with the body as a readable-stream that needs to be cloned - I was assuming that the Web Cache would already need to implement such behavior. I'll step out of discussions of implementation details now if someone else is willing to take over.
I have somehow interest to implement it...
@Uzlopak I'm very time poor so I'm more than happy to step back on my side! Note you'll probably want to implement rfc9111 which appears to obsolete rfc7234.
from undici.
I am also not very time "rich", but I already investigated some hours in reading into rfc 9111.
The only thing which was not clear to me, is how we ensure that we dont open a security issue :D
What I mean is:
In a browser context you have one user and fetch calls can be cached, as the cache is user scoped. In node we dont have users. So a http cache would be globally activated (?) in nodejs.
So we need to have something like setGlobalDispatcher but for caching? setGlobalHttpCache?
from undici.
I've implemented http-cache-semantics by reading the RFC start to finish, and translating each paragraph into code.
I highly recommend that approach, because it results in good comments with references to their RFC sections (I wish I kept more of them in my code), and helps ensure that unobvious behaviors are not missed.
from undici.
Usually when I implement an RFC or any other spec I print it out. Then like you say, use the text for commenting the code. When I implemented a paragraph I mark it in the print out that it was implemented, too. Yellow marker for implemented, pink marker for has an issue and should be checked again. When the whole text is colored, then I know the spec is implemented completely ;).
from undici.
Related Issues (20)
- bug: spreading `Headers` object has breaking behavior in versions between Node 20.12 and 20.13 HOT 9
- Limit the maximum numbers of open sockets HOT 2
- interceptors: move `throwOnError` to interceptor HOT 2
- interceptors: move signal handling to interceptor
- Support for custom proxy auth schemes HOT 7
- Nightly tests are failing HOT 2
- do not encode with encodeURIComponent if query with method GET passed. HOT 4
- Retry Handler Fails When Request Has a Body HOT 5
- autobahn workflow is always 1 commit behind HOT 1
- Nightly tests are failing HOT 3
- (regression?) timeouts while reading a body no longer abort with a TimeoutError HOT 2
- Body timeout not working HOT 5
- Retrieve the URL when errored HOT 1
- SocketError: other side closed (with repro example) HOT 1
- Fetch failed with UND_ERR_CONNECT_TIMEOUT undici error on Next.js serverless function HOT 1
- 'interceptors' export doesn't work like in the docs HOT 1
- Nightly tests are failing HOT 4
- publish autobahn test results on the docs site HOT 7
- Nightly tests are failing HOT 2
- Improve support for pre-shared sessions (PSK) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from undici.