-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
Middleware for Downloader #102
Comments
That would be pretty tricky to implement because it would essentially break the entire downloader pipeline. Right now, each request is run through each A possible way to deal with this could be, extending the You could then implement a caching middleware by simply setting the cached response on the request inside a regular class CachingMiddleware implements RequestMiddlewareInterface
{
public function handleRequest(Request $request): Request
{
// assuming the cache returns `null` if no cached response exists, it's safe
// to always set the result of `forRequest` on the request.
$cachedResponse = $this->cache->forRequest($request);
return $request->setResponse($cachedResponse);
}
} This would still allow the other middlewares to run as usual which is something I definitely want to preserve. |
That's a great way of doing it, i'll work on adding that, Thanks! |
@aaronflorey @ksassnowski Do you have a more complete working version of this caching middleware? I've not been able to get it to work and would appreciate your help, thanks. |
While having RequestMiddleware and ResponseMiddleware is awesome, what are your thoughts on a Downloader middleware that takes a request and returns a response?
An example use case is the JavascriptMiddleware, which could take the request and render the page, which then returns the response itself, instead of running it through the downloader and then overwriting the response. The other use case would be caching requests between runs.
I'm sure there's a reason why this isn't already a thing, so i was wondering what would need to be done to get this implemented? I'm happy to contribute to get it done
The text was updated successfully, but these errors were encountered: