- Communication failures and timeouts
- The ability to move off a page and then back
- Bookmarked pages
- The refresh button
- The infamous back-button
These causes can result in the equivalent of a partitioned system between client and server. The CAP theorem states that there is a trade-off between Consistency, Availability, and Partition tolerance. In all web-applications, the choice has been made for Availability and Partition tolerance over Consistency. The availability choice may not be obvious; it is a result of choosing not to indefinitely lock up the user's web browser.
Fielding's thesis on RESTful design proposes a design pattern to minimize the potential inconsistency. Quite simply, try to make the server as stateless as possible. If the server has no state, there is nothing to be for the client to be inconsistent with.
Fielding recognized that the application server is responsible calculating the "next state" (in most cases). He relaxed the server-stateless constraint by allowing the state to move from client to server and back again. Hence there is State Transfer in REST.
That state transfer from server back to client can be found in the HTML template process. A template is often filled in with content and links specific to a state. Another good example is the addition of hidden elements within a form. Those hidden elements provide additional context (or state) to the server.
Generally, an application is RESTful if the server retains no session state between requests. There are some places where keeping session state is useful. For example, keeping authentication (signed-in) state is very useful.
***
That state transfer from server back to client can be found in the HTML template process. A template is often filled in with content and links specific to a state. Another good example is the addition of hidden elements within a form. Those hidden elements provide additional context (or state) to the server.
Generally, an application is RESTful if the server retains no session state between requests. There are some places where keeping session state is useful. For example, keeping authentication (signed-in) state is very useful.
***
But what about RESTful API's?
Those are RESTful on a small scale and are part of making an application RESTful. But just providing RESTful API's does't mean that the application is RESTful.
***
No comments:
Post a Comment