Truncate response body on cache hits#55
Conversation
Adding tests ETag and Last-Modified to ensure the response body shouldn't send data when their is a cache hit.
Replacing the response body on cache hits to reduce data transmission
| $this->type = $type; | ||
| $this->maxAge = $maxAge; | ||
| $this->mustRevalidate = $mustRevalidate; | ||
| $this->streamFactory = $streamFactory; |
There was a problem hiding this comment.
Maybe for now it's better to add slim/psr7 and call StreamFactory this would make it easier for anyone already using this package?
There was a problem hiding this comment.
I'd rather require psr/http-factory (and likely psr/http-factory-implementation) than slim/psr7 as it keeps interoperable with other psr7 implementation packages
There was a problem hiding this comment.
Only the user should decide which StreamFactoryInterface implementation should be used in their application.
There was a problem hiding this comment.
@flavioheleno @odan thank you for taken the time to review the PR I’ll update when I get some time.
|
I've been thinking about this approach. Wouldn't it be easier to implement a custom middleware that checks the response for status code 304 and, if the case, returns a response with an empty body. The advantage would be that this can be added when needed and doesn't break the existing logic. |
|
Honestly, dropping the body is something that I'd expect from this middleware and not have to add another one to handle it. |
Removig StreamFactory as it's not used.
This means that we don't break BC.
|
I've updated to make the |
truncating the body to reduce data transmission on cache hits.
closes #54