Search code examples
resthttpstateless

RESTful web requests and user activity tracking websites


Someone asked me this question a couple of days ago and I didn't have an answer:

As HTTP is a stateless protocol. When we open www.google.com, can it be called a REST call?

What I think:

When we make a search on google.com all info is passed through cookie and URL parameters. It looks like a stateless request. But the search results are not independent of user's past request. Search results are specific to user interest and behavior. Now, it doesn't look like a stateless request.

I know this is an old question and I have read many SO answers like Why HTTP is a stateless protocol? but I am still not able to understand what happens when user activity is tracked like on google or Amazon(recommendations based on past purchases) or any other user activity based recommendation websites.

Is it RESTful or is it RESTless?

What if I want to create a web app in which I use REST architecture and still provide user-specific responses?


Solution

  • HTTP is stateless, however the Google Application Layer is not. The specific Cookies and their meaning is part of the Application Layer.

    Consider the same with TCP/IP. IP is a stateless protocol, but TCP isn't. The existence of state in TCP embedded in IP packets does not mean that IP protocol itself has a state.

    So does that make it a REST call? No.

    Although HTTP is stateless & I would suspect that www.google.com when requested with cookies disabled, the results would be the same for each request, making it almost stateless (Google still probably tracks IP to limit request frequency).

    But the Application Layer is not stateless. One of the principles of REST is that the system does not retain state data about about the client between requests for the purpose of modifying the responses. In the case of Google, that clearly is not happening.