Search code examples
restweb-applicationsasp.net-web-apirestful-architecturestateless

Statelessness of REST


I am creating a REST service that has two methods one is GetAll and other is GetById.In my scenario, database request is very costly so i want to store output of GetAll somewhere (Cache) and use it for subsequent request GetById.

One of the characteristic of REST is it should be Statelessness. A request cannot be dependent on a past request and a service treats each request independently. I want to understand what should be ideal approach to handle such scenarios or how to design this requirement in REST?


Solution

  • The requirement for statelessness in REST is that the service should appear to be stateless. It doesn't matter if the service maintains some state internally. That's just an implementation detail.