ok2c commented on PR #420:
URL:
https://github.com/apache/httpcomponents-client/pull/420#issuecomment-1465140391
@arturobernalg I now understood your response better. It turns out that now
the same `Cache-Control` header gets parsed twice, once by
`#isExplicitlyNonCacheable` and again by `#calculateFreshnessLifetime`, which
is bad and must be fixed. The parsing code should be extracted from
`#calculateFreshnessLifetime` and enhanced to include the main cache control
directive that the `#isExplicitlyNonCacheable` could use to make its decision:
```
if (isExplicitlyNonCacheable(response)) {
LOG.debug("Response is explicitly non-cacheable");
return false;
}
// calculate freshness lifetime
final Duration freshnessLifetime =
calculateFreshnessLifetime(response);
if (freshnessLifetime.isNegative() || freshnessLifetime.isZero()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Freshness lifetime is invalid");
}
return false;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]