Home > Software engineering >  What should the HTTP response code be for an endpoint whose role is to load a server cache?
What should the HTTP response code be for an endpoint whose role is to load a server cache?

Time:03-30

I need to create an endpoint that loads a server cache when called (for instance "POST cache/load") but I don't want that endpoint to load the cache if it's already loaded. Therefore, I want to differentiate, in my responses, the two following cases :

  • "I loaded the cache, everything went fine"
  • "The cache is already loaded, everything is fine"

Now the question is, what are the appropriate HTTP response codes ?

I currently use 201 when the cache has been loaded and 200 if the cache is already loaded.

CodePudding user response:

Now the question is, what are the appropriate HTTP response codes ?

200 for both. That's all that the components in the transfer of documents over a network domain need to know.

The implementation specific details belong in the body of the response.

  • Related