Subject: A fresh stale response

From: Alex Rousskov <[email-masked]>
Date: Thu, 12 May 2016 18:21:23 -0600

Hello,

    I need help navigating a pair of semi-conflicting RFC 7234 MUSTs.

Imagine a cache that has a stored response A with a Date value X. The
cache sends a conditional request to validate that cached response. The
cache receives a 200 OK response B with a Date value of Y.

If X <= Y, then the situation is clear -- A is stale and the cache
should use B.

What if X > Y? In other words, what if the cache receives a 200 OK
response B that appears to be older (i.e., even more stale) than the
response A the cache is trying to validate? Should the cache trust the
sender's staleness decision or its own date comparison logic?

* RFC 7234 section 4 says "a cache MUST use the most recent response (as
determined by the Date header field)". That means A wins.

* RFC 7234 section 4.3.3 says "the cache MUST use the full response [it
just received]". That means B wins.

* RFC 2616 section 13.2.5 says "If a client performing a retrieval
receives a non-first-hand response for a request that was already fresh
in its own cache, and the Date header in its existing cache entry is
newer than the Date on the new response, then the client MAY ignore the
response". That means A wins if A was fresh and B came from a cache.

If I have to guess, I would use B if it does not have an Age header,
boldly assuming that it is a first-hand response. Otherwise, use A. With
more time/effort, revalidating with max-age=0 would be a good option
(but it may result in the same conundrum).

Is this a gray area, or did I miss a specific HTTPbis rule that resolves
this conflict? Was the quoted RFC 2616 MAY replaced with something
equally specific? If this is a gray area, what do you recommend?

Thank you,

Alex.

---

From: Martin Thomson <[email-masked]>
Date: Fri, 13 May 2016 10:33:56 +1000

On 13 May 2016 at 10:21, Alex Rousskov <[email-masked]> wrote:
> What if X > Y?

So time just went backwards?  I assume that this is the result of two
requests that are fairly close to each other in time, to different
nodes in a cluster, with some non-trivial clock skew between the two.
That's possible, I suppose.

It's all grey/gray to me.  When such things happen, it's tempting to
just throw up your hands and invoke the gods of undefined behaviour
and do whatever is easiest for you.