W3C home > Mailing lists > Public > public-lod@w3.org > March 2020

Conditional Linked Data requests are broken in browsers

From: Martynas Jusevičius <martynas@atomgraph.com>
Date: Mon, 23 Mar 2020 10:19:14 +0100
Message-ID: <CAE35VmwWTb3hF1p2AiKqQi97zU72u1w4JLecmgH143zo5nH7og@mail.gmail.com>
To: public-lod <public-lod@w3.org>
Cc: julian.reschke@gmx.de

as we know, Linked Data relies heavily on HTTP content negotiation to
serve multiple representations for the same URL.

Conditional requests, on the other hand, are a useful mechanism for
improving performance by saving bandwidth using ETag/Last-Modified
response headers and If-(None-)Match/If-Modified-Since request headers

I was unpleasantly surprised to figure out that something I took for
granted wasn't true.

Namely, browsers only store one representation per URL in their cache.
In other words, they ignore Vary in conditional requests.

This can be illustrated with such conditional request example:

Request 1:
GET /foo
Accept: text/html

ETAG: "1"
Vary: Accept

Request 2:
GET /foo
Accept: application/json
If-None-Match: "1"

ETAG: "2"
Vary: Accept

Request 3:
GET /foo
Accept: text/html
If-None-Match: "2"

This is taken from a description of a Chromium bug, which has been
WONTFIX since 2011 [2].

In a more real-world scenario, our application loads RDF/XML from the
same URL as the HTML document. Just like in the example above, the
browser always uses the latest ETag it has seen and therefore sends
RDF representation's ETtag when requesting HTML, and conversely HTML
representation's ETag when requesting RDF. So they never match on the
server, and we always get 200 and not 304.
We experienced that with Firefox and Edge. More on that on StackOverflow [3].

I cannot judge whether the HTTP specification defines this well enough.
In any case, I think it's safe to say that the behaviour of all major
browsers is broken.

[1] https://tools.ietf.org/html/rfc7232
[2] https://bugs.chromium.org/p/chromium/issues/detail?id=94369
[3] https://stackoverflow.com/questions/60799116/firefox-if-none-match-headers-ignore-content-type-and-vary/60802443
Received on Monday, 23 March 2020 09:19:40 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 March 2020 09:19:41 UTC