Conditional Linked Data requests are broken in browsers

Hi,

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
[1].

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