Answer the question
In order to leave comments, you need to log in
Web application architecture?
I ask the audience for help in choosing the application architecture.
What you want: JSON API.
There are two types of queries:
1. parameterized, the result of which is arrays of structured data (like reading)
2. receiving structured data (like writing)
. I wouldn’t want to do different ways to transfer data (say, for the first option, these are URI parameters, and for the second, JSON POST). Those. I would like both types of requests to be accepted as JSON POST. So it is clearer and more uniform.
However, there is a problem with caching. Queries of the first type return data that rarely changes. I would like not to drag them from the database, but to cache them. I can't find a way to cache JSON POST requests, let's say to nginx. It is clear that queries of the second type do not need to be cached.
Now it’s done like this: everything is sent by JSON POST, php is received, JSON request is parsed, all parameters are checked, the type of request is determined, a cache hash is created by the parameters, whether there are results in the cache, the cache is returned or the database is requested. I would like to somehow do without the participation of php-fpm.
Answer the question
In order to leave comments, you need to log in
Use the REST API, this will be unification and standardization.
GET, POST, PUT, DELETE
it is not entirely clear why the JSON POST name is needed if all the parameters fit in the URI, that is, there are no objects or the serialization is primitive. I would just do GET and POST.
Do the uniformity of GET and POST through $ _REQUEST, if all the same JSON POST then just $ _GET element by element we write it into the object, as if it were from JSON POST, and then we parse it.
It looks like caching is not quite correctly written in the question. nginx caches GET perfectly, you just need to set the key to something like
proxy_cache_key "$request_method|$http_if_modified_since|$http_if_none_match|$host|$request_uri";
and POST is just not cached and it seems like it’s not necessary. So the problem seems to be solved automatically.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question