views:

38

answers:

2

We have a resource on a REST server ie

  • /someResources/1
  • /someResources/2
  • /someResources/3

where "someResource" is a server representation of a distributed object far away.

We want to tell the server to "refresh" its representation of that "distributed object" by looking at it out in the network & updating the server's cache ie we can not simply PUT the new value.

What is the clean REST way to this ?

a) Is it to POST to a /refreshes/ a new "refresh request" ?

b) Is it to PUT (with a blank document) to http://ip/someResources ?

c) Something else ?

I like (a) as it will give us an id to identify & track the refresh command but worried that we are creating too many resources?

Thanks

Kieran

A: 

HTTP caching seems to allow for this. http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.1.6

Set the header max-age=0 and this will instruct the server that the client wants a new version. This way you can just continue using a GET.

Darrel Miller
Thanks Darrel, HTTP caching would be good if the refresh was quick but ...I should have explained it takes several minutes to do the refresh hence the idea of a REST resource - "refreshes".I THINK now that the /Refreshes/ can handle both initial retrieval and future refresh operations i.e. it supports a POST with a options set of identifiers to refresh (e.g. "1,2,5" means 1 and 2 need "refreshed", 5 to be retrieved, and 3 which was previously cached is ignored)So if the set of identifiers is null ... refresh for ALL currently cached representations.I think this makes sense ???
k79
I did something similar once where I created a collection resource called /RefreshRequests If I did a GET on /RefreshRequests I could see a history of requests that had been initiated. Individual requests can be assigned an id so that GET /RefreshRequest/232 could return a current status of the request.
Darrel Miller
A: 

Hi,

I would go with the 'refreshes' resource approach. This has two major benefits

(a) Like life-cycle operations (copy, clone, move) the purpose of the refresh is orthogonal to the function of the underlying resource so should be completely separate

(b) It gives you some way of checking the progress of the refresh - the external state of the refresh resource would provide you with a 'status' or 'progress' attribute.

We've implemented the life-cycle operations this way and the separation of concerns is a big design plus.

Chris

Chris McCauley