- Building RESTful Web Services with PHP 7
- Haafiz Waheed ud din Ahmad
- 320字
- 2021-07-03 00:02:15
Stateless
Client server communication is stateless. Each request coming from the client will have all the information required to serve a request. This means there is no state in this communication other than what is in the request. The response which the client will get will be based on the request without looking at any state other than what is in request.
If the session needs to be maintained, the session will be stored based on a token or identifier which is coming in the request. So if we look at an example of a web request, then the flow of HTTP is no more than a request sent by the client to the server and a response, sent back to the client from the server, as shown in the following diagram:

If a session needs to be maintained, the session data will be stored on the server, while the session identifier will be sent back to the client. In subsequent requests, the client will include that session identifier in every request by which the server will identify the client and load the related session's data as explained in the following diagram:

And in subsequent requests:

So REST is stateless. To maintain the state, one needs to pass an identifier or any other information, to logically group different requests to maintain a session in the request. If no such identifier is passed in the request, the server will never know if those two requests are from same client.
The advantage of statelessness is simplicity. The same requests will not result in different responses unless the request parameters are changed. It will return different results based on different request parameters not due to some sort of state. Even the state depends on requests, as shown in the preceding example. So that session identifier is in the request, which can result in a different state and, hence, results in a different response.
- C# 7 and .NET Core Cookbook
- 程序設計與實踐(VB.NET)
- AWS Serverless架構:使用AWS從傳統部署方式向Serverless架構遷移
- Python自動化運維快速入門
- FreeSWITCH 1.6 Cookbook
- Python Game Programming By Example
- 精通軟件性能測試與LoadRunner實戰(第2版)
- PhpStorm Cookbook
- Learn React with TypeScript 3
- Scientific Computing with Scala
- R大數據分析實用指南
- Cocos2d-x學習筆記:完全掌握Lua API與游戲項目開發 (未來書庫)
- C/C++程序員面試指南
- 軟件測試綜合技術
- Building Business Websites with Squarespace 7(Second Edition)