title: Caching responses based on date and age headers
body: <p>We're seeing some behaviour where we aren't caching responses in OkHttp, and end up hitting the server every time.  However, the response has an Expires time in the future, so ideally it would be cached.</p>
  <p>Here's a simple example of headers we're seeing in the response (request was sent and response was received at <code>Sat, 16 Jan 2021 00:40:36 GMT</code>):</p>
  <pre><code>date: Sat, 16 Jan 2021 00:40:36 GMT
  age: 6
  expires: Sat, 16 Jan 2021 00:40:40 GMT
  last-modified: Sat, 16 Jan 2021 00:40:30 GMT
  </code></pre>
  <p>From what I've seen from looking at the CacheStrategy, the problem is that it adds together date + age to see if it's past the expiry time.  In this case, <code>00:40:36 + 6 = 00:40:42 &gt; 00:40:40</code>, so it ends up not being added to the cache.</p>
  <p>So I think ideally, either the response date would be equal to last-modified (in this case Sat, 16 Jan 2021 00:40:30 GMT), or we'd need to have a custom CacheStrategy to use last-modified instead of date for these calculations.</p>
  <p>If anyone has any insights into whether I'm making any bad assumptions, or if one of the above options is preferable, please let me know.  I've looked at some of the specs for date/age headers and it's a bit unclear to me what they should be in this scenario.</p>
  <p>I've also found it a bit difficult to debug the caching behaviour in OkHttp, right now I've just been using conditional breakpoints to try to trace it, but if anyone has a better idea I'd appreciate that as well.</p>