Statelessness Provide credentials with the request. Each request MUST stand alone and should not be affected from previous conversation happened from same client in past.
The server never relies on information from previous requests.
Statelessness
As per the REST (REpresentational “State” Transfer) architecture, the server does not store any state about the client session on the server side. This restriction is called Statelessness. 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. client is responsible for storing and handling all application state related information on client side.
It also means that client is responsible for sending any state information to server whenever it is needed. There should not be anysession affinity or sticky sessions on server.
To enable clients to access these stateless APIs, its necessary that servers also should include every piece of information that client may need to create state on it’s side.
For becoming stateless, do not store even authentication/authorization details of client. Provide credentials with the request. Each request MUST stand alone and should not be affected from previous conversation happened from same client in past.
Application State vs Resource State
Please do not confuse between application state and resource state. Both are completely different things.
Application state is server-side data which servers store to identify incoming client requests, their previous interaction details and current context information.
Resource state is the current state of a resource on server at any point of time – and it has nothing to do with interaction between client and server. It is what you get as response from server as API response. You refer to it as resource representation.
REST statelessness means being free on application state.
Advantages of Statelessness
There are some very noticeable advantages for having REST APIs stateless.
- Statelessness helps in scaling the APIs to millions of concurrent users by deploying it to multiple servers. Any server can handle any request because there is no session related dependency.
- Being stateless makes REST APIs less complex – by removing all server side state synchronization logic.
- A stateless API is also easy to cache as well. A specific software can decide whether or not to cache the result of an HTTP request just by looking at that one request. There’s no nagging uncertainty that state from a previous request might affect the cacheability of this one. It improves the performance of applications.
- The server never loses track of “where” each client is in the application, because the client sends all necessary information with each request.
Reference: Roy T. Fielding on Stateless
Statelessness Provide credentials with the request. Each request MUST stand alone and should not be affected from previous conversation happened from same client in past.的更多相关文章
- String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";作用!!!!!
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+re ...
- C#中 Request, Request.params , Request.querystring , Request.Form 区别 与联系用法
C#中 Request, Request.params , Request.querystring , Request.Form 区别 与联系用法? Request.params , Request ...
- basePath = request.getScheme()+"://"+request.getServerName()+":"+r
basePath = request.getScheme()+"://"+request.getServerName()+":"+r (2014-06-30 1 ...
- String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+pat----------<base>元素有关
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. ...
- request.get request.GET……
发现他们是不同的. 报错: AttributeError at /add/ 'WSGIRequest' object has no attribute 'get' Request Method: GE ...
- 客户端的数据来源:QueryString, Form, Cookie Request[]与Request.Params[]
在ASP.NET编程中,有三个比较常见的来自于客户端的数据来源:QueryString, Form, Cookie . 我们可以在HttpRequest中访问这三大对象. QueryString: 获 ...
- JSP之项目路径问题(${pageContext.request.contextPath},<%=request.getContextPath()%>以及绝对路径获取)
本随笔这是作为一个记录使用,以备后查.项目完成之后本地部署OK,本地Linux部署OK,都可以正常的访问,可是当我把它部署到服务器上面的时候,首页可以正常访问,可是当发出请求的时候却报错误了,说找不到 ...
- 安卓开发笔记(十六):'Request(okhttp3.Request.Builder)' has private access in 'okhttp3.Request
当出现了'Request(okhttp3.Request.Builder)' has private access in 'okhttp3.Request的错误的时候,实际上是我们在写代码的时候少打了 ...
- <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+re ...
随机推荐
- nginx的报错500
500:服务器内部错误,也就是服务器遇到意外情况,而无法履行请求. 500错误一般有几种情况: 1. web脚本错误,如php语法错误,lua语法错误等. 2. 访问量大的时候,由于系统资源限制,而不 ...
- 刷题总结——鸭舌(ssoi)
题目: 题目背景 CF 77C 题目描述 小美喜欢吃鸭舌.有一个 n 个点的树,每个节点 i ,第 i 个点上有 ai 个鸭舌.小美一开始处于 x 号点.每次小美可以选择一个与现在的点有边的点而且那个 ...
- 大逃杀(树上dp)
这道题和宝藏差不多吧,转移的时候比较麻烦的. 代码中分量很多种情况. h更新比较麻烦 这两幅图表示了双边更新中3,4连个h更新,下面比较好理解的吧. #include<cstring> # ...
- hdu 5288 ZCC loves straight flush
传送门 ZCC loves straight flush Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K ...
- linux下查看隐藏文件
linux下查看隐藏文件的快捷键:Ctrl+H 命令:ls -a
- 关于Properties 集 添加数据 遍历数据
public static void fun1(){ Properties v = new Properties(); v.setProperty("a","1" ...
- Java中循环与选择语句
public class Ifelse{ public static void main(String [] args){ int score=98; if(score>=90&& ...
- android DatePicker使用
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=&q ...
- Invalid regular expression: unmatched parentheses
Unmatched ) in Javascript regular expression您的某些字符串包含错误')'.你需要逃避这个.这是这样做的功能: function escapeRegExp(s ...
- 查询公司外网ip方法
curl -s "http://checkip.dyndns.org/"|cut -f 6 -d" "|cut -f 1 -d"<" ...