rocicorp / replicache

Realtime Sync for Any Backend Stack
https://doc.replicache.dev
1.06k stars 38 forks source link

Cookies v2: send some subset of client view in request #581

Open aboodman opened 3 years ago

aboodman commented 3 years ago

We currently have a simple cookie feature that act like the original HTTP cookies -- the server returns a value in /replicache-pull and the client sends that value in next request.

We've run into a number of cases where it would be convenient if these cookie values were visible to client-side script, like how document.cookie is in web browsers. See #301 for example.

I think that we should deprecate the cookie feature as-is and replace it with sending some subset of the keyspace in requests. I would propose that the keyspace that we send is configurable, but initially just: /cookie/*.

aboodman commented 3 years ago

Hat-tip to @whiten who originally proposed this idea.

KeKs0r commented 3 years ago

I have some use cases where it would be interesting for the client to read the cookie. One of them would be to signal after a pull, that there is still more data. Having a dedicated pull handler to inspect the response of a pull and potentially do another pull is quite straight forward. If the cookie would be moved into the key space, reading it from other patches would be little bit more complicated and reading it from the storage, would make the interaction quite indirect (currently it is a simple request/response).

I generally support the idea of harmonizing the data space and cookie space, just maybe enabling some API that make the described case as simple as it is right now. Maybe a sync read api for the cookie data.