-
Notifications
You must be signed in to change notification settings - Fork 499
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
Implement HTTP caching #3231
Comments
I've looked into implementing this as an interceptor, and need some information in order to proceed:
|
Can you elaborate on what you have in mind?
The closest implementation will be the |
I have somehow interest to implement it... |
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.
@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. |
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? |
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 ;). |
Ok, i will start tonight. ;) |
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. |
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 ;). |
This would solve...
Performance and robustness issues associated with fetching the same HTTP resource multiple times.
The implementation should look like...
Use an interceptor(?) to implement http caching using the
Cache-Control
header. I'm inclined to think that theExpires
header should not be implemented as http 1.0 has extremely limited use.Additional context
Originally raised in #3221.
The text was updated successfully, but these errors were encountered: