RE: Conditional HTTP requests in read/write Linked Data

Just a thought, Martin,

This sounds like an application where a canonicalized form of RDF might be useful?

The RDFC spec (https://www.w3.org/TR/rdf-canon/) is coming to the end of its Candidate Rec phase and I'm hoping we can advance to Proposed Rec next month. If it's useful to you now, that would be good to know.

Phil

On Friday, February 9, 2024 10:46 PM, Martynas Jusevičius wrote:
Hi,

I'm implementing conditional requests in a read-write Linked Data API and am looking for some existing material on the topic.

I have found a few previous posts on ETags but not much:
https://github.com/solid/specification/issues/340

https://www.w3.org/2012/ldp/track/issues/10


My understanding re. ETags for RDF responses is:
* strong ETags should be used on specific serializations of an RDF document, e.g. as a tuple <hash(graph), media-type>. Not byte-for-byte identical as triple order can differ for identical graphs.
* weak ETags should be used to indicate graph equivalence regardless of the serialization, e.g. as hash(graph).

Just to illustrate this with some HTTP pseudo-examples (please ignore any incomplete RDF syntax):

# Strong ETags

GET /foo
Accept: application/n-triples

200 OK
Content-Type: application/n-triples
ETag: "123-nt"

<http://s> <http://p> <http://o> .


GET /foo
Accept: application/n-triples

200 OK
Content-Type: application/n-triples
ETag: "123-rdfxml"

<rdf:RDF>
    <rdf:Description rdf:about="http://s">
        <http:p rdf:resource="http://o"/>
    </rdf:Description>
</rdf:RDF>

# Weak ETags

GET /foo
Accept: application/n-triples

200 OK
Content-Type: application/n-triples
ETag: W/"123"

<http://s> <http://p> <http://o> .


GET /foo
Accept: application/n-triples

200 OK
Content-Type: application/n-triples
ETag: W/"123"

<rdf:RDF>
    <rdf:Description rdf:about="http://s">
        <http:p rdf:resource="http://o"/>
    </rdf:Description>
</rdf:RDF>

We are using strong ETags in our system. I have a feeling I've tried weak ETags as described above and they caused issues either with browser caching or proxy caching, but I could also be making this up...

As for updating RDF documents, non-safe methods such as PUT require strong ETags for conditional request validation (using the If-Match header [2]).

Would you agree with my summary? Are you using conditional requests with your Linked Data?
I'd be interested in others' experience on this topic, especially on updating data.

Martynas
atomgraph.com

[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Conditional_requests

[2] https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-semantics-19#section-13.1.1


CONFIDENTIALITY / DISCLAIMER: The contents of this e-mail are  confidential and are not to be regarded as a contractual offer or acceptance from GS1 (registered in Belgium). 
If you are not the addressee, or if this has been copied or sent to you in error, you must not use data herein for any purpose, you must delete it, and should inform the sender. 
GS1 disclaims liability for accuracy or completeness, and opinions expressed are those of the author alone. 
GS1 may monitor communications. 
Third party rights acknowledged. 
(c) 2020.

Received on Saturday, 10 February 2024 09:48:41 UTC