Re: Cache control in trailers?

Hey James,

> On 4 Feb 2021, at 2:32 am, James M Snell <jasnell@gmail.com> wrote:
> 
> One of the likely challenges here is that if a failure happens during
> the transmission of the response the server may not even be able to
> add a trailer.

That's explicitly out of scope here -- HTTP already defines how to handle truncated / badly delimited responses.[1] This is really just 'I changed my mind about caching policy because something happened while I was generating the response.' Although, see below.


> Just musing on a slightly different approach... what if we could have
> a Cache-Control directive that says, "Only cache if a given trailer is
> received (signaling success)".
> 
> In the response headers we'd have...
> 
>  Cache-Control: cache-on-trailer
> 
> Then, only at the end of a successfully transmitted response we'd have
> the trailer:
> 
>  Cache-Control: cache-commit
> 
> The assumption here would be that if the commit trailer is not
> received the assumption is that the response should not be cached.

That's definitely interesting. In my mind, the important thing to consider here is whether we think this mechanism is going to be used by content that's currently marked as cacheable or uncacheable; it may well be the latter, in which case this approach makes a lot of sense.

If we specify it really carefully, it might also be possible to define its interaction with other cache directives in a way that allows the origin to still control the behaviour of non-implementing caches.

Also, an extension taking this approach probably should define whether or not the commit is valid if the response is truncated; I'd assume it's not. It'd also need to talk about the relationship to collapsed requests,[2] as Ryan alludes to.

I might start working on a draft; would you like to co-author?

Cheers,


1. https://httpwg.org/http-core/draft-ietf-httpbis-cache-latest.html#incomplete.responses
2. https://httpwg.org/http-core/draft-ietf-httpbis-cache-latest.html#constructing.responses.from.caches

--
Mark Nottingham   https://www.mnot.net/

Received on Thursday, 4 February 2021 00:03:44 UTC