Restful Flashcards
What is Rest?
Representational State Transfer is a software architectural style that defines a set of constraints to be used for creating Web Services.
Web Services that conform to the Rest Architectural style, called Restful Web Services, provide interoperability between computer systems on the net.
What makes a service Restful?
In the Rest architectural style, data and functionality are considered resources and are accessed using Uniform resource Identifiers (URIs), The resources are acted upon by using a set of simple, well-defined operations.
What protocols and data format do Rest services use?
JSON is a format, commonly associated with REST services, even though REST itself is format agnostic. That means that, while JSON is the most commonly used format, Rest allows you to user XML, HTML, pure text, any format.
What are the architectural constraints of Rest?
The 6 constraints are: Stateless Client/Server Cacheable Layered Architecture Uniform Interface Code on Demand
What is Stateless?
Each request from client to server must contain all of the information necessary to understand the request, and cannot take advantage of any stored context on the server. Session state is therefore kept entirely on the client.
What is Cacheable?
Cache constraints require that the data within a response to a request be implicitly or explicitly labeled as cacheable or non-cacheable. If a response is cacheable, then a client cache is given the right to reuse that response data for later, equivalent requests.
What is Uniform Interface?
By applying the software engineering principle of generality? to the component interface, the overall system architecture is simplified and the visibility of interactions is improved. In order to obtain a uniform interface, multiple architectural constraints are needed to guide the behavior of components.
identification of resources
manipulation of resources through representations
self-descriptive messages
hypermedia as the engine of application state.
What is a Layered System?
The layered system style allows an architecture to be composed of hierarchical layers by constraining component behavior such that each component cannot “see” beyond the immediate layer with which they are interacting.
What is client-server
By separating the user interface concerns from the data storage concerns, we improve the portability of the user interface across multiple platforms and improve scalability by simplifying the server.components
What is Code on Demand?
Rest allows client functionality to be extended by downloading and executing code in the form of Applets or Scripts. This simplifies clients by reducing the number of features required to be pre-implemented.
What is Caching?
the ability to store copies of frequently accessed data in several places along the request-response path.
By using HTTP headers, a origin server indicates whether a response can be cached and, if so, by whom, and for how long. Caches along the response path can take a copy of a response, but only if the caching metadata allows them to do so.
What are the pros and cons of Caching?
Optimizing the network using caching imporves the overall quality-of-service in the following ways: Reduce bandwidth Reduce latency reduce load on servers Hide network failures
What should be Cacheable?
Get requests by default unless otherwise specified
Post requests are NOT by default, but can be if an Expires or Cache-Control header with a directive, to explicitly allow caching, is added to the response.
Put and Delete requests are NOT cacheable at all.
What is Expires? (Caching)
The Expires HTTP header specifies an absolute expiry time for a cached representation.
Beyond that time, a cached representation is considered stale and must be re-validated with the origin server.
What is Cache-Control?
The header value comprises one or more comma-separated directives. The directives determine whether a response is cacheable, and if so, by whom, and for how long.