Re: Prefer: return=representation and caching

Mark Nottingham <mnot@mnot.net> Tue, 23 June 2020 00:06 UTC

Return-Path: <ietf-http-wg-request+bounce-httpbisa-archive-bis2juki=lists.ie@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 479ED3A14A1 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Mon, 22 Jun 2020 17:06:09 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.749
X-Spam-Level:
X-Spam-Status: No, score=-2.749 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=mnot.net header.b=ihTbVWqS; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=KngDS9af
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WPTZi3ungKnK for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Mon, 22 Jun 2020 17:06:05 -0700 (PDT)
Received: from lyra.w3.org (lyra.w3.org [128.30.52.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 256503A149C for <httpbisa-archive-bis2Juki@lists.ietf.org>; Mon, 22 Jun 2020 17:06:05 -0700 (PDT)
Received: from lists by lyra.w3.org with local (Exim 4.92) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1jnWOK-0002NA-7n for ietf-http-wg-dist@listhub.w3.org; Tue, 23 Jun 2020 00:02:20 +0000
Resent-Date: Tue, 23 Jun 2020 00:02:20 +0000
Resent-Message-Id: <E1jnWOK-0002NA-7n@lyra.w3.org>
Received: from mimas.w3.org ([128.30.52.79]) by lyra.w3.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <mnot@mnot.net>) id 1jnWOI-0002MO-Up for ietf-http-wg@listhub.w3.org; Tue, 23 Jun 2020 00:02:18 +0000
Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by mimas.w3.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <mnot@mnot.net>) id 1jnWOG-0004ZM-TD for ietf-http-wg@w3.org; Tue, 23 Jun 2020 00:02:18 +0000
Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 0C9613DF; Mon, 22 Jun 2020 20:02:01 -0400 (EDT)
Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 22 Jun 2020 20:02:02 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mnot.net; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=fm3; bh=k JpOyhuPiiCtU+SW3TMH8a70BVWLT8g/Z2U6JabOvIo=; b=ihTbVWqS/AuIqeQ1I PnOc/zDlFfJld9wGp2YcaOG+U4TTM+amWrTM7BxJ0IxGJvS+LZId3l1XNL8pw5GR fzwQtmbi5yqd5hizJznnXhruy2uhI1wduiepa1Qze6RwqRzy/zoNKMCjd/2BmjjM MhqQr0sO4nNxqJkJUUyzcin00GDCZ1LOuUQqWnKpQZvFroohSIHVwCvhumxNgYEH lTLBpxkMpF8D++Opzj0jgRJTqA3SUv3ZnYLS8CJcHxidAYB1cxmAGOsDDDMkbWtD NbLJByR05g2AqPmj/JqOjfbc9kF4/MJOieMnx92sou7rz6goyAGBZzHZYB9TCOLC Jy96A==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=kJpOyhuPiiCtU+SW3TMH8a70BVWLT8g/Z2U6JabOv Io=; b=KngDS9afRU5zF/U0gKf2NuplrrD8QArGiPMwNrUR8IsHOWOFIJ9yefPfD iZCOsNm40R0aNxbR+LebXnGzUGsFkq/Z7y2rALSJWI4KjNci9DYUbNVVksZRpuar ejoAyH68kL+hqdgbYaLRpunFTm21YUmceXMW/EyzwryqXEdD8FQeZ0nbPT15D22V dC51zcCKxLhfWmOlu6zcLFXrIkkZcTi2g6mL1S80oAgflDdIKlK6j3Ze5p11eWLe R4CrLwsReoC0YkkgddrnVDIneBZNga75bk/lhpwOln9QgfLnx4kz1cZ/lwEiFZfd 8chPj12zd5LV9q34IDjE7a6KbUlAA==
X-ME-Sender: <xms:eEbxXt-Q-oFQ3zzjlthth1VH9nDeXkmbu9ixAiY0fA5SbFR-y2FugQ>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudekfedgvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurheptggguffhjgffgffkfhfvofesthhqmhdthhdtvdenucfhrhhomhepofgrrhhk ucfpohhtthhinhhghhgrmhcuoehmnhhothesmhhnohhtrdhnvghtqeenucggtffrrghtth gvrhhnpedttddutdevudefveefudeuvedvheetueeigeevvedvjeefvdejgfejudffkeff geenucffohhmrghinhephhhtthhpfihgrdhorhhgpdhmnhhothdrnhgvthenucfkphepud duledrudejrdduheekrddvhedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghm pehmrghilhhfrhhomhepmhhnohhtsehmnhhothdrnhgvth
X-ME-Proxy: <xmx:eEbxXhslYq26JvKxGITLs_wy6m2ylx1JjRqLbp4sVJG3LqGxyN2LYw> <xmx:eEbxXrBmZJZDj3Ey1_fpwhHZ2QbFDitt2ko-DVmxvxpYO27nxjPgUg> <xmx:eEbxXhdFJcwE4ly8DxbKTK5I90I7VZgCf7mhk56F3ZiVClQHqhrtEw> <xmx:eUbxXk08YddGglFihVjAvjMb_19a_VVH2c223NGDw4Fg-qnVyF-6RA>
Received: from macbook-air.mnot.net (119-17-158-251.77119e.mel.static.aussiebb.net [119.17.158.251]) by mail.messagingengine.com (Postfix) with ESMTPA id 0CF6E3280059; Mon, 22 Jun 2020 20:01:59 -0400 (EDT)
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\))
From: Mark Nottingham <mnot@mnot.net>
In-Reply-To: <3c80ab15-3fea-04b9-f0b8-76d6864d0143@fastmail.com>
Date: Tue, 23 Jun 2020 10:01:57 +1000
Cc: ietf-http-wg@w3.org
Content-Transfer-Encoding: quoted-printable
Message-Id: <1573ADD4-39AF-4AD4-A937-70949DEBD6AD@mnot.net>
References: <3c80ab15-3fea-04b9-f0b8-76d6864d0143@fastmail.com>
To: Ken Murchison <murch@fastmail.com>
X-Mailer: Apple Mail (2.3608.80.23.2.2)
Received-SPF: pass client-ip=64.147.123.20; envelope-from=mnot@mnot.net; helo=wout4-smtp.messagingengine.com
X-W3C-Hub-Spam-Status: No, score=-9.8
X-W3C-Hub-Spam-Report: BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, W3C_AA=-1, W3C_DB=-1, W3C_IRA=-1, W3C_IRR=-3, W3C_WL=-1
X-W3C-Scan-Sig: mimas.w3.org 1jnWOG-0004ZM-TD 65a5edbfddfac65b6af9d723d91782c1
X-Original-To: ietf-http-wg@w3.org
Subject: Re: Prefer: return=representation and caching
Archived-At: <https://www.w3.org/mid/1573ADD4-39AF-4AD4-A937-70949DEBD6AD@mnot.net>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/37810
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <https://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

Hi Ken,

> On 15 Jun 2020, at 3:07 am, Ken Murchison <murch@fastmail.com> wrote:
> 
> All,
> 
> Does Prefer: return=representation have any effect on the cacheability of PUT and/or POST responses?  I ask the question in a theoretical sense, not what is actually implemented in the wild.
> 
> Consider a scenario where resources stored on the origin server may differ slightly from the actual resources sent in client requests, e.g. CalDAV with scheduling resources.

Just to be clear on terminology here - you mean '...from the actual representations sent in responses to clients', correct?


> For instance, a CalDAV client will typically make a request such as (Content-* headers and body not included for brevity):
> 
> PUT /calendar/event1.ics HTTP/1.1
> Prefer: return=representation
> 
> 
> to avoid the extra round-trip of a subsequent GET to fetch the actually stored resource.  The server would respond with something like:
> 
> HTTP/1.1 200 OK
> Preference-Applied: return=representation
> Content-Location: /calendar/event1.ics
> Cache-Control: no-cache, maxage=60
> ETag: abc
> 
> 
> Since the response body for the PUT request is equivalent to the response body for a GET request (post-PUT) on the same URI, can/should the response be cacheable?

As currently specified, PUT is not cacheable; see the bottom of <https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#PUT>.

That could be modified by a carefully thought out cache extension, but it would need to be specified; e.g., something like 
  Cache-Control: cacheable-put
... or maybe something more generic, like:
  Cache-Control: response-is-representation
(but probably less wordy)


> Similarly, for the same reason, a client may do:
> 
> POST /calendar;add-member HTTP/1.1
> Prefer: return=representation
> 
> 
> and receive:
> 
> HTTP/1.1 201 Created
> Location: /calendar/event2.ics
> Preference-Applied: return=representation
> Content-Location: /calendar/event2.ics
> Cache-Control: no-cache, maxage=60
> ETag: xyz
> 
> 
> Can/should this response be cacheable for /calendar/event2.ics?

POST *is* cacheable; see <https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#POST>. Note that by this, we mean that future GET and HEADs can be satisfied by a cached POST response; future POSTSs will still write through to the origin. Also, POST caching is not widely implemented (at all).

Cheers,


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