Stateless web application, an urban legend?

前端 未结 3 1996
忘了有多久
忘了有多久 2021-02-06 03:58

I am trying to understand token-based authentication these days, which claims to be a stateless authentication method. And I met the concept of s

3条回答
  •  别跟我提以往
    2021-02-06 04:08

    OK, I don't think that the term stateless web application makes any sense. What does make sense is stateless protocol. And stateless protocol is a one that treats each request independently.

    So in your case if you send an auth token with each request than it is stateless. That's how HTTP authentication is supposed to work.

    On the other hand if you would send auth token only once and each consecutive request wouldn't have to (for example because server knows that this TCP connection is alredy authenticated) then this means that each request depends on the authentication request. This makes the protocol stateful.

    Stateless protocols are easier to scale, easier to proxy, etc.

    Now as for web applications the term may or may not make sense depending on the definition. I don't know any reasonable though.

    Side note: being stateful/stateless is unrelated to sharing data between client and server.

提交回复
热议问题