Answer the question
In order to leave comments, you need to log in
Filtering in GET in RESTful
Hello! I have been tormented by the question for a long time:
let's say the application has a REST api, let's say it supports requests like this:
GET /rest-api/models/?idModel=1,2,3,4,5,6,...
Answer the question
In order to leave comments, you need to log in
It turns out, for the sake of RESTful principles, should I degrade performance?
the same POST request that has id-shniki in the body will be much cooler
In a POST request, it will not be cooler. caching will not work.
A more curious question is whether processing N requests to get objects is actually slower than processing 1 request to get N objects. Provided that the client sends all requests through one HTTP connection, and the server uses persistent connections with the DBMS. If the objects are heavy enough, the extra overhead can be small. Now if we take into account that the caching granularity has increased and the client will not request the same object twice, it may turn out that N requests will work faster. And if the client and server support SPDY and the requests go not sequentially but in parallel, then at the cost of increasing the load on the server, we can get a decrease in response time. Now a low response time seems to be appreciated.
There is another interesting question: why did the client need to request many models from the server by ID? What unites these objects? This is some entity that is on the client, but which the server does not know about. Perhaps it is worth introducing this entity and the problem will disappear.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question