Per Resource Events Protocol (PREP)
by Rahul Gupta
The Per Resource Events Protocol (PREP) provides an alternative mechanism for notifications in Solid. These slides explain the fundamental concepts of PREP.
Video
Transcript
The Per Resource Events Protocol provides an alternative mechanism for notifications in Solid. The Per Resource Events Protocol, or PREP, is predicated on the idea that the most intuitive source for notifications about changes made to a resource is the resource itself.
The most common scenario for notifications involves applications requesting some content, and thereafter tracking changes to that content. PREP is optimized for just this use case. Using PREP, applications can receive the current representation of a resource followed by notifications, all with one HTTP request.
To request PREP notifications from a Solid hosted resource, all you need to do is to include just one additional header with your HTTP request.
If the resource supports PREP, it will send a multipart response with the current representation followed by notifications. The notifications part is itself a multipart message, wherein each part is a single notification sent when an event occurs on the resource.
The Per Resource Events Protocol allows for notifications to be content-negotiated, just like representations. A resource may generate different notifications for a given event, which can communicate different information about the event or transmit the information in different formats. For example, a notification may provide metadata about the event, or it may be the delta between the previous and current representations. Depending on the application, clients can negotiate their preferred form of notifications.
The companion Solid-PREP specification ensures that, for resources hosted on Solid PODS, PREP notifications are identical to Solid Notifications, thus making the two mechanisms complementary.
If your application needs to leverage channels that use different protocols, such as WebSockets or webhooks, you should prefer Solid Notifications. But, if you wish to receive content and notifications from a resource over a single HTTP request, PREP is the way to go.
A full suite of Connect/Express style middlewares is now available for servers to implement Per Resource Events.
Client applications can easily consume PREP notifications using the Fetch PREP library, which splits a Fetch response into a series of notification responses, each with an API identical to Fetch.
Finally, we expect PREP to be implemented in the Node Solid Server by the time you see this video at TPAC 2024.
So what are you waiting for? PREP your Solid apps for notifications, today!